package hu.elte.txtuml.api.model.execution.impl.seqdiag.fragments.execstrats;

import java.util.Queue;

import hu.elte.txtuml.api.model.seqdiag.BaseCombinedFragmentWrapper;
import hu.elte.txtuml.api.model.seqdiag.BaseFragmentWrapper;
import hu.elte.txtuml.api.model.seqdiag.BaseMessageWrapper;

public class ExecutionStrategySeq implements ExecutionStrategy {

	@Override
	public boolean containsMessage(Queue<BaseFragmentWrapper> containedFragments, BaseMessageWrapper message) {
		BaseFragmentWrapper wrapper = containedFragments.peek();
		if (wrapper instanceof BaseCombinedFragmentWrapper) {
			return ((BaseCombinedFragmentWrapper) wrapper).containsMessage(message);
		} else {
			return wrapper.equals(message);
		}
	}

	@Override
	public boolean checkMessageSendToPattern(Queue<BaseFragmentWrapper> containedFragments,
			BaseMessageWrapper message) {
		BaseFragmentWrapper fragment = containedFragments.peek();
		if (fragment instanceof BaseCombinedFragmentWrapper) {
			return ((BaseCombinedFragmentWrapper) fragment).checkMessageSendToPattern(message);
		} else {
			BaseMessageWrapper required = (BaseMessageWrapper) fragment;
			if (!required.equals(message)) {
				return false;
			}
			containedFragments.remove();
			return true;
		}
	}

}

@@ -964,38 +964,48 @@
 ntWrapper) %7B%0A%09%09%09
-return
+boolean result =
  ((BaseCombinedF
@@ -1058,32 +1058,137 @@
 ttern(message);%0A
+%09%09%09%0A%09%09%09if (result && fragment.size() == 0) %7B%0A%09%09%09%09containedFragments.remove();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09return result;%0A
 %09%09%7D else %7B%0A%09%09%09Ba

Fix a bug with normal execution mode