Java Code Examples for org.eclipse.emf.ecore.EStructuralFeature#isUnsettable()

The following examples show how to use org.eclipse.emf.ecore.EStructuralFeature#isUnsettable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseSession.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean useUnsetBit(EStructuralFeature feature, IdEObject object) {
	// TODO non-unsettable boolean values can also be stored in these bits
	Object value = object.eGet(feature);
	if (feature.isUnsettable()) {
		if (!object.eIsSet(feature)) {
			return true;
		}
		if (feature.isMany() && ((List<?>)value).isEmpty()) {
			return true;
		}
	} else {
		if (feature.isMany() && ((List<?>)value).isEmpty()) {
			return true;
		}
		if (feature.getDefaultValue() == value || (feature.getDefaultValue() != null && feature.getDefaultValue().equals(value))) {
			return true;
		}
	}
	return false;
}
 
Example 2
Source File: CheckUnsettable.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {
	int nrFeatures = 0;
	int nrUnsettableFeatures = 0;
	for (EClassifier eClassifier : Ifc2x3tc1Package.eINSTANCE.getEClassifiers()) {
		if (eClassifier instanceof EClass) {
			EClass eClass = (EClass)eClassifier;
			for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) {
				nrFeatures++;
				if (eStructuralFeature.isUnsettable()) {
					nrUnsettableFeatures++;
				} else {
					System.out.println(eClass.getName() + "." + eStructuralFeature.getName());
				}
			}
		}
	}
	System.out.println(nrUnsettableFeatures + " / " + nrFeatures);
}
 
Example 3
Source File: HashMapVirtualObject.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean useUnsetBit(EStructuralFeature feature) {
	// TODO non-unsettable boolean values can also be stored in these bits
	Object value = eGet(feature);
	if (feature.isUnsettable()) {
		if (!eIsSet(feature)) {
			return true;
		}
	} else {
		if (feature.isMany() && (value == null || ((List<?>)value).isEmpty())) {
			return true;
		}
		if (feature.getDefaultValue() == value || (feature.getDefaultValue() != null && feature.getDefaultValue().equals(value))) {
			return true;
		}
	}
	return false;
}
 
Example 4
Source File: IfcStepSerializer.java    From IfcPlugins with GNU Affero General Public License v3.0 5 votes vote down vote up
private void writeObject(IdEObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object ref = object.eGet(feature);
	if (ref == null || (feature.isUnsettable() && !object.eIsSet(feature))) {
		EClassifier type = feature.getEType();
		if (type instanceof EClass) {
			EStructuralFeature structuralFeature = ((EClass) type).getEStructuralFeature(WRAPPED_VALUE);
			if (structuralFeature != null) {
				String name = structuralFeature.getEType().getName();
				if (name.equals(IFC_BOOLEAN) || name.equals(IFC_LOGICAL) || structuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()) {
					print(BOOLEAN_UNDEFINED);
				} else {
					print(DOLLAR);
				}
			} else {
				print(DOLLAR);
			}
		} else {
			if (type == EcorePackage.eINSTANCE.getEBoolean()) {
				print(BOOLEAN_UNDEFINED);
			} else if (feature.isMany()) {
				print("()");
			} else {
				print(DOLLAR);
			}
		}
	} else {
		if (ref instanceof EObject) {
			writeEmbedded((EObject) ref);
		} else if (feature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
			writeDoubleValue((Double)ref, object, feature);
		} else {
			IfcParserWriterUtils.writePrimitive(ref, outputStream);
		}
	}
}
 
Example 5
Source File: IfcStepStreamingSerializer.java    From IfcPlugins with GNU Affero General Public License v3.0 5 votes vote down vote up
private void writeObject(HashMapVirtualObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object ref = object.eGet(feature);
	if (ref == null || (feature.isUnsettable() && !object.eIsSet(feature))) {
		EClassifier type = feature.getEType();
		if (type instanceof EClass) {
			EStructuralFeature structuralFeature = ((EClass) type).getEStructuralFeature(WRAPPED_VALUE);
			if (structuralFeature != null) {
				String name = structuralFeature.getEType().getName();
				if (name.equals(IFC_BOOLEAN) || name.equals(IFC_LOGICAL) || structuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()) {
					print(BOOLEAN_UNDEFINED);
				} else {
					print(DOLLAR);
				}
			} else {
				print(DOLLAR);
			}
		} else {
			if (type == EcorePackage.eINSTANCE.getEBoolean()) {
				print(BOOLEAN_UNDEFINED);
			} else if (feature.isMany()) {
				print("()");
			} else {
				print(DOLLAR);
			}
		}
	} else {
		if (ref instanceof HashMapWrappedVirtualObject) {
			writeEmbedded((HashMapWrappedVirtualObject) ref);
		} else if (feature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
			EStructuralFeature asStringFeature = object.eClass().getEStructuralFeature(feature.getName() + "AsString");
			String asString = (String) object.eGet(asStringFeature);
			writeDoubleValue((Double)ref, asString, feature);
		} else {
			IfcParserWriterUtils.writePrimitive(ref, printWriter);
		}
	}
}
 
Example 6
Source File: ByteBufferVirtualObject.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean useUnsetBit(EStructuralFeature feature) {
	// TODO non-unsettable boolean values can also be stored in these bits
	if (feature.isUnsettable()) {
		return true;
	} else {
		if (feature.isMany()) {
			return true;
		}
		if (feature.getDefaultValue() == null || (feature.getDefaultValue() != null && feature.getDefaultValue() == null)) {
			return true;
		}
	}
	return false;
}