if (!feature.getEType().isInstance(referencedObject)) { throw new BimserverDatabaseException(referencedObject.getClass().getSimpleName() + " cannot be stored in list of type " + feature.getEType().getName() + " for feature " + feature.getName());
/** * Returns the first collection member that {@link EClassifier#isInstance is an instance} of the type. * @param objects a collection of objects to check. * @param type the type of object to find. * @return the first object of the specified type. */ public static Object getObjectByType(Collection<?> objects, EClassifier type) { for (Object object : objects) { if (type.isInstance(object)) { return object; } } return null; }
for (Object o : list) { IdEObject ref = (IdEObject)o; if (targetFeature.getEType().isInstance(ref)) { if (converted.containsKey(o)) { toList.addUnique(converted.get(o));
/** * Returns the first collection member that {@link EClassifier#isInstance is an instance} of the type. * @param objects a collection of objects to check. * @param type the type of object to find. * @return the first object of the specified type. */ public static Object getObjectByType(Collection<?> objects, EClassifier type) { for (Object object : objects) { if (type.isInstance(object)) { return object; } } return null; }
public boolean isKindOf(Object object, EClassifier classifier) { // special case for Integer/UnlimitedNatural and Real which // are not related types in java but are in OCL if ((object.getClass() == Integer.class) && (classifier.getInstanceClass() == Double.class)) { return Boolean.TRUE; } else if (classifier instanceof AnyType) { return Boolean.TRUE; } return classifier.isInstance(object); }
@Override protected boolean isInstance(Class cls, EObject element) { EClassifier eclass = getEClassifier(cls, element); return (eclass != null) && eclass.isInstance(element); } };
protected boolean isInstance(Object object) { return getFeatureType().isInstance(object); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ private static boolean typeCompatible(EClassifier type, Object value) { if (type instanceof EEnum) { return (((EEnum)type).getEEnumLiteralByLiteral(value.toString()) != null); } else { return type.isInstance(value); } }
protected boolean isInstance(Object object) { return getFeatureType().isInstance(object); }
@SuppressWarnings("unchecked") public void copyDecomposes(IdEObject ifcObjectDefinition, IdEObject ownerHistory) throws IfcModelInterfaceException, ObjectAlreadyExistsException { IdEObject newObjectDefinition = copy(ifcObjectDefinition, false, skipRepresentation); EStructuralFeature decomposesFeature = newObjectDefinition.eClass().getEStructuralFeature("Decomposes"); for (IdEObject ifcRelDecomposes : (List<IdEObject>)ifcObjectDefinition.eGet(decomposesFeature)) { copy(ifcRelDecomposes, false, skipRepresentation); EStructuralFeature relatingObjectFeature = ifcRelDecomposes.eClass().getEStructuralFeature("RelatingObject"); IdEObject relatingObject = (IdEObject) ifcRelDecomposes.eGet(relatingObjectFeature); if (relatingObject != null) { copyDecomposes(relatingObject, ownerHistory); } } if (ifcObjectDefinition.eClass().getEPackage().getEClassifier("IfcElement").isInstance(ifcObjectDefinition)) { EStructuralFeature containedInStructureFeature = ifcObjectDefinition.eClass().getEStructuralFeature("ContainedInStructure"); for (IdEObject containedInStructure : (List<IdEObject>)ifcObjectDefinition.eGet(containedInStructureFeature)) { IdEObject newContainedInSpatialStructure = getTargetModel().create(containedInStructure.eClass()); newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("GlobalId"), GuidCompressor.getNewIfcGloballyUniqueId()); newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("OwnerHistory"), ownerHistory); EStructuralFeature relatedElementsFeature = newContainedInSpatialStructure.eClass().getEStructuralFeature("RelatedElements"); ((List<IdEObject>)newContainedInSpatialStructure.eGet(relatedElementsFeature)).add(newObjectDefinition); EStructuralFeature relatingStructureFeature = containedInStructure.eClass().getEStructuralFeature("RelatingStructure"); IdEObject newRelatingStructre = copy(((IdEObject)containedInStructure.eGet(relatingStructureFeature)), false, skipRepresentation); newContainedInSpatialStructure.eSet(relatingStructureFeature, newRelatingStructre); getTargetModel().add(oidProvider.newOid(newContainedInSpatialStructure.eClass()), newContainedInSpatialStructure); copyDecomposes((IdEObject)containedInStructure.eGet(relatingStructureFeature), ownerHistory); } } }
public void validate(Object value) { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName(); throw new ClassCastException ("The feature '" + eStructuralFeature.getName() + "'s type '" + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'"); } }
public void validate(Object value) { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName(); throw new ClassCastException ("The feature '" + eStructuralFeature.getName() + "'s type '" + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'"); } }
protected void validate() { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName(); throw new ClassCastException ("The feature '" + eStructuralFeature.getName() + "'s type '" + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'"); } }
protected void validate() { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName(); throw new ClassCastException ("The feature '" + eStructuralFeature.getName() + "'s type '" + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'"); } }
@Override protected boolean isInstance(Object object) { return dataClass == null ? getFeatureType().isInstance(object) : super.isInstance(object); }
@Override protected boolean isInstance(Object object) { return dataClass == null ? getFeatureType().isInstance(object) : super.isInstance(object); }
protected void assertValue(EStructuralFeature feature, Object value) { if (!feature.getEType().isInstance(value)) { String valueType = value == null ? "null" : value.getClass().getSimpleName(); String featureName = feature.eClass().getName() + "." + feature.getName(); throw new RuntimeException("The value of type '" + valueType + "' can not be assigned to feature " + featureName + " of type '" + feature.getEType().getName() + "'."); } }
@Override protected Adapter createAdapter(Notifier target) { ResourceSet resourceSet = getGenerator().getOptions().resourceSet; EPackage.Registry packageRegistry = resourceSet != null ? resourceSet.getPackageRegistry() : EPackage.Registry.INSTANCE; EPackage ePackage = packageRegistry.getEPackage(modelPackage); if (ePackage != null) { EClassifier eClassifier = ePackage.getEClassifier(modelClass); if (eClassifier.isInstance(target)) { adapter = (GeneratorAdapter)createInstance(); return (Adapter)createInstance(); } } return null; }
@Override protected Adapter createAdapter(Notifier target) { ResourceSet resourceSet = getGenerator().getOptions().resourceSet; EPackage.Registry packageRegistry = resourceSet != null ? resourceSet.getPackageRegistry() : EPackage.Registry.INSTANCE; EPackage ePackage = packageRegistry.getEPackage(modelPackage); if (ePackage != null) { EClassifier eClassifier = ePackage.getEClassifier(modelClass); if (eClassifier.isInstance(target)) { adapter = (GeneratorAdapter)createInstance(); return (Adapter)createInstance(); } } return null; }
/** * Returns a wrapped set command that returns as its affected object the replacement wrapper for the value. * A feature map entry is also created for the value, and used as the value of the set command. */ @Override protected Command createSetCommand(EditingDomain domain, Object owner, Object feature, Object value, int index) { // Check that the value is type compatible with the entry feature. // if (getEntryFeature().getEType().isInstance(value)) { FeatureMap.Entry entry = FeatureMapUtil.createEntry(getEntryFeature(), value); return new ReplacementAffectedObjectCommand(SetCommand.create(domain, this.owner, this.feature, entry, this.index)); } return UnexecutableCommand.INSTANCE; }