use of org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationsResource in project winery by eclipse.
the class GenericArtifactsResource method findInterface.
private Optional<TInterface> findInterface(EntityTypeId id, String interfaceName) {
TInterface i;
List<TInterface> interfaces = new ArrayList<>();
IRepository repository = RepositoryFactory.getRepository();
if (this.res instanceof NodeTypeImplementationResource || this.res instanceof NodeTypeImplementationsResource) {
TNodeType nodeType = repository.getElement((NodeTypeId) id);
if (nodeType.getInterfaces() != null) {
interfaces.addAll(nodeType.getInterfaces());
}
} else if (this.res instanceof RelationshipTypeImplementationResource || this.res instanceof RelationshipTypeImplementationsResource) {
TRelationshipType relationshipType = repository.getElement((RelationshipTypeId) id);
if (relationshipType.getSourceInterfaces() != null) {
interfaces.addAll(relationshipType.getSourceInterfaces());
}
if (relationshipType.getTargetInterfaces() != null) {
interfaces.addAll(relationshipType.getTargetInterfaces());
}
if (relationshipType.getInterfaces() != null) {
interfaces.addAll(relationshipType.getInterfaces());
}
}
Iterator<TInterface> it = interfaces.iterator();
do {
i = it.next();
if (i.getName().equals(interfaceName)) {
return Optional.of(i);
}
} while (it.hasNext());
return Optional.empty();
}
Aggregations