public static Collection<Feature> getInheritedFeatures(Structure structure) { Set<Feature> result = Sets.newLinkedHashSet(); for (Inheritable supertype : structure.getAllSupertypes()) { if (supertype instanceof Structure) { result.addAll(((Structure) supertype).getOwnedFeatures()); } } return result; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public EList<Inheritable> getAllSupertypes() { Set<Inheritable> allSupertypes = Sets.newLinkedHashSet(); Set<Inheritable> supertypeComputationInProgress = SUPERTYPE_COMPUTATION_IN_PROGRESS.get(); if (supertypeComputationInProgress.add(this)) { // does not contain the current type try { allSupertypes.addAll(getSupertypes()); if (!allSupertypes.contains(this)) { // StackOverflow otherwise for (Inheritable supertype : getSupertypes()) { if (supertype instanceof Structure) { allSupertypes.addAll(((Structure) supertype).getAllSupertypes()); } } } } finally { supertypeComputationInProgress.remove(this); } } // We need an org.eclipse.emf.ecore.util.InternalEList for proper Eclipse rename refactoring // Apparently InternalEList is expected for multi-valued features, see https://www.eclipse.org/forums/index.php/t/130207/ return new EcoreEList.UnmodifiableEList.FastCompare<Inheritable> (this, RapidmlPackage.eINSTANCE.getStructure_AllSupertypes(), allSupertypes.size(), allSupertypes.toArray()); }
@Check public void checkCircularInheritance(Structure type) { if (type.getAllSupertypes().contains(type)) { error("Circular inheritance, please check that the supertype hierarchy does not contain loops", type, RapidmlPackage.Literals.STRUCTURE__SUPERTYPES); } }
private void checkReferencePropertyRestrictionType(ReferenceProperty validatedProperty, Feature overriddenProperty) { Structure restrictionType = validatedProperty.getType(); if (overriddenProperty instanceof ReferenceProperty) { Structure overriddenType = ((ReferenceProperty) overriddenProperty).getType(); if (overriddenType == restrictionType) {// same type return; } if (restrictionType.getAllSupertypes().contains(overriddenType)) {// covariance return; } String message = String.format( "The type of property '%s' is incompatible with inherited property type: '%s'", validatedProperty.getName(), overriddenType.getName()); error(message, validatedProperty, RapidmlPackage.Literals.REFERENCE_PROPERTY__TYPE); } }
private Multimap<String, FeatureHierarchy> getInheritedFeaturesMap(Structure structure) { Multimap<String, FeatureHierarchy> result = ArrayListMultimap.create(); if (structure.getAllSupertypes().contains(structure)) { return result;