package de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes;


import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Node_Types;
import de.uni_stuttgart.vis.vowl.owl2vowl.export.JsonGeneratorVisitor;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.BaseNode;

import java.util.List;

public class OwlUnionOf extends SpecialClass {
	public OwlUnionOf() {
		super();
		setType(Node_Types.TYPE_UNION);
	}

	public void addUnion(BaseNode node) {
		if (node == null) {
			return;
		}

		unionOf.add(node);
	}

	public boolean equalsUnion(List<BaseNode> classes) {
		for (BaseNode aClass : classes) {
			if (!unionOf.contains(aClass)) {
				return false;
			}
		}

		return true;
	}

	public boolean equalUnionIris(List<String> iriList) {
		int equalIris = 0;

		for (String aIri : iriList) {
			for (BaseNode aUnion : unionOf) {
				if (aUnion.getIri().equals(aIri)) {
					equalIris++;
					break;
				}
			}
		}

		return equalIris == iriList.size();
	}

	@Override
	public void accept(JsonGeneratorVisitor visitor) {
		super.accept(visitor);
		visitor.visit(this);
	}
}

@@ -758,41 +758,8 @@
 0;%0A%0A
-%09%09for (String aIri : iriList) %7B%0A%09
 %09%09fo
@@ -770,22 +770,24 @@
 aseNode 
-aUnion
+baseNode
  : union
@@ -799,46 +799,51 @@
 %0A%09%09%09
-%09
 if (
-aUnion.getIri().equals(aIri
+iriList.contains(baseNode.getIri()
 )) %7B%0A
-%09
 %09%09%09%09
@@ -859,26 +859,8 @@
 ++;%0A
-%09%09%09%09%09break;%0A%09%09%09%09%7D%0A
 %09%09%09%7D
@@ -887,23 +887,59 @@
 Iris == 
-iriList
+unionOf.size() && iriList.size() == unionOf
 .size();

Fix bug with wrongly detected unions.