Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes #120
If the subset is a type with subtypes and the set is a type set of the
subtypes, we now expand the type with subtypes and assure each is
contained.
  • Loading branch information
reteprelief committed Jan 10, 2017
1 parent 329023c commit 3431540
Showing 1 changed file with 34 additions and 1 deletion.
Expand Up @@ -102,7 +102,23 @@ public static boolean contains(ErrorTypes constraint, ErrorType type) {
return contains((ErrorType) constraint, type);
}
if (constraint instanceof TypeSet) {
return contains((TypeSet) constraint, type);
ErrorModelLibrary el = EMV2Util.getContainingErrorModelLibrary(type);
EList<ErrorType> subtypes = null;
if (el != null) {
subtypes = getAllLeafSubTypes(type, el);
} else {
subtypes = getAllLeafSubTypes(type, EMV2Util.getUseTypes(type));
}
if (subtypes.isEmpty()) {
return contains((TypeSet) constraint, type);
} else {
for (ErrorType st : subtypes) {
if (!contains((TypeSet) constraint, st)) {
return false;
}
}
return true;
}
}
return false;
}
Expand Down Expand Up @@ -606,6 +622,23 @@ public static EList<ErrorType> getAllLeafSubTypes(ErrorType et, List<ErrorModelL
return result;
}

public static EList<ErrorType> getAllLeafSubTypes(ErrorType et, ErrorModelLibrary el) {
EList<ErrorType> result = new UniqueEList<ErrorType>();
EList<ErrorType> removeMe = new UniqueEList<ErrorType>();
Iterable<ErrorType> typeslist = ErrorModelUtil.getAllErrorTypes(el);
for (ErrorType errorType : typeslist) {
ErrorType set = EMV2Util.resolveAlias(errorType);
if (contains(et, set) && (et != set)) {
result.add(set);
}
if (set.getSuperType() != null) {
removeMe.add(set.getSuperType());
}
}
result.removeAll(removeMe);
return result;
}

/**
* map a TypeToken into a target type token according to the TypeMappingSet.
* The original token is not modified.
Expand Down

0 comments on commit 3431540

Please sign in to comment.