public EClass getRandomInstantiableSubClassOrSelf(EClass eType) { List<EClass> list = inheritedSubClasses.get(eType); EClass result = null; if (random.nextInt(list.size() + 1) == 0) { result = eType; } else { result = list.get(random.nextInt(list.size())); } if (result.isAbstract() || result.isInterface()) { return getRandomInstantiableSubClassOrSelf(eType); } else { return result; } } }
/** * TODO To complete. * * @param cls * @param st */ private boolean isExtends(final EClass cls, EGenericType st) { final EClass cls2 = (EClass) st.getEClassifier(); return cls2.isInterface() && cls.isInterface() || !cls2.isInterface() && !cls.isInterface(); }
/** * TODO To complete. * * @param cls * @param st */ private boolean isImplements(final EClass cls, EGenericType st) { final EClass cls2 = (EClass) st.getEClassifier(); return !cls.isInterface() && cls2.isInterface(); }
@Override protected boolean isMapped(EClass eClass) { return !eClass.isAbstract() && !eClass.isInterface(); }
/** * Returns whether this {@code ClassBean} represents an interface. * * @return {@code true} if this {@code ClassBean} represents an interface, {@code false} otherwise */ public boolean isInterface() { return get().isInterface(); }
public String getInterfaceFlag() { String result = !getEcoreClass().isInterface() ? "!" : ""; return result + "IS_INTERFACE"; }
public String getInterfaceFlag() { String result = !getEcoreClass().isInterface() ? "!" : ""; return result + "IS_INTERFACE"; }
public boolean isInterface() { return getEcoreClass().isInterface(); }
public boolean isInterface() { return getEcoreClass().isInterface(); }
/** * Retrieves the superclass of this {@code ClassBean}. * * @return an {@link Optional} containing the representation of the direct superclass, or {@link Optional#empty()} * if the class has no superclass */ @Nonnull public Optional<ClassBean> inheritFrom() { return get().getESuperTypes() .parallelStream() .filter(c -> !c.isInterface()) .map(ClassBean::from) .findAny(); }
public EObject create(EClassifier classifier) { if (classifier == null) throw new NullPointerException("Classifier may not be null."); if (!(classifier instanceof EClass)) throw new IllegalArgumentException("Cannot create instance of datatype '" + classifier.getName() + "'"); EClass clazz = (EClass) classifier; if (clazz.isAbstract() || clazz.isInterface()) throw new IllegalArgumentException("Cannot create instance of abstract class '" + clazz.getName() + "'"); if (classifier.eIsProxy()) throw new IllegalStateException("Unresolved proxy "+((InternalEObject)classifier).eProxyURI()+". Make sure the EPackage has been registered."); return clazz.getEPackage().getEFactoryInstance().create(clazz); }
private boolean isInstantiatableSubType(EClass c, EClass superType) { return !c.isAbstract() && !c.isInterface() && EcoreUtil2.isAssignableFrom(superType, c); }
/** * Retrieves all subclasses of this {@code ClassBean}. * * @return a immutable {@link Set} containing the representation of all non-abstract subclasses that inherit, * directly and indirectly, from this {@code ClassBean} */ @Nonnull public Set<ClassBean> inheritedBy() { final EClass eClass = get(); final Predicate<EClass> isInheritedBy = c -> !c.isInterface() && !c.isAbstract() && eClass.isSuperTypeOf(c); return eClass.getEPackage().getEClassifiers() .parallelStream() .filter(EClass.class::isInstance) .map(EClass.class::cast) .filter(isInheritedBy) .map(ClassBean::from) .collect(Collectors.toSet()); }
public boolean isAbstract() { // An interface should be abstract, but this makes sure of that fact. // return getEcoreClass().isAbstract() || getEcoreClass().isInterface(); }
public boolean isAbstract() { // An interface should be abstract, but this makes sure of that fact. // return getEcoreClass().isAbstract() || getEcoreClass().isInterface(); }
public static void collectSourceCandidates(EClass eClass, EReference eReference, Collection<EClass> concreteTypes, Map<EClass, List<EReference>> sourceCandidates) { if (!eClass.isAbstract() && !eClass.isInterface()) { if (!eReference.isContainer() && !eReference.isContainment()) { if (canReference(eReference.getEReferenceType(), concreteTypes)) { List<EReference> list = sourceCandidates.get(eClass); if (list == null) { list = new ArrayList<EReference>(); sourceCandidates.put(eClass, list); } list.add(eReference); } } } }
/** * Validates the InterfaceIsAbstract constraint of '<em>EClass</em>'. * <!-- begin-user-doc --> * A class that is an interface must be abstract. * <!-- end-user-doc --> * @generated NOT */ public boolean validateEClass_InterfaceIsAbstract(EClass eClass, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = !eClass.isInterface() || eClass.isAbstract(); if (!result && diagnostics != null) { diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, INTERFACE_IS_ABSTRACT, "_UI_EClassInterfaceNotAbstract_diagnostic", null, new Object[] { eClass, EcorePackage.Literals.ECLASS__ABSTRACT }, context)); } return result; }
public static void collectSourceCandidates(EClass eClass, Collection<EClass> concreteTypes, Map<EClass, List<EReference>> sourceCandidates) { if (!eClass.isAbstract() && !eClass.isInterface()) { for (EReference eReference : CDOModelUtil.getClassInfo(eClass).getAllPersistentReferences()) { collectSourceCandidates(eClass, eReference, concreteTypes, sourceCandidates); } } }
/** * @since 4.1 */ protected void createExtent(EClass eClass, IStoreAccessor accessor, CDOBranch branch, long timeStamp, final AtomicBoolean canceled, CDORevisionHandler revisionHandler) { if (!eClass.isAbstract() && !eClass.isInterface()) { accessor.handleRevisions(eClass, branch, timeStamp, false, revisionHandler); } CDOPackageRegistry packageRegistry = accessor.getStore().getRepository().getPackageRegistry(); List<EClass> subTypes = packageRegistry.getSubTypes().get(eClass); if (subTypes != null) { for (EClass subType : subTypes) { if (canceled.get()) { break; } accessor.handleRevisions(subType, branch, timeStamp, false, revisionHandler); } } }
private static EClass getAnyConcreteEClass(EPackage ePackage) { for (EClassifier classifier : ePackage.getEClassifiers()) { if (classifier instanceof EClass) { EClass eClass = (EClass)classifier; if (!(eClass.isAbstract() || eClass.isInterface())) { return eClass; } } } for (EPackage subpackage : ePackage.getESubpackages()) { EClass eClass = getAnyConcreteEClass(subpackage); if (eClass != null) { return eClass; } } return null; }