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

The following examples show how to use org.eclipse.emf.ecore.EStructuralFeature#isTransient() . 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: GrammarGeneratorTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private boolean addImportedEPackages(EPackage ePackage, Set<EPackage> importedEPackages) {
	if (BROKEN_PACKAGE_NS_URIS.contains(ePackage.getNsURI())) {
		return false;
	}
	if (importedEPackages.add(ePackage)) {
		for (EClassifier eClassifier : ePackage.getEClassifiers()) {
			if (eClassifier instanceof EClass) {
				for (EStructuralFeature feature : ((EClass) eClassifier).getEAllStructuralFeatures()) {
					if (!feature.isTransient() && !feature.isDerived()) {
						EPackage referencedEPackage = feature.getEType().getEPackage();
						if (referencedEPackage == null) {
							return false;
						}
						if (feature instanceof EAttribute) {
							if (((EAttribute) feature).getEAttributeType().isSerializable()) {
								if (!addImportedEPackages(referencedEPackage, importedEPackages)) {
									return false;
								}
							}
						}
						if (feature instanceof EReference) {
							if (((EReference) feature).isContainment()) {
								if (!addImportedEPackages(referencedEPackage, importedEPackages)) {
									return false;
								}
							}
						}
					}
				}
			}
		}
	}
	return true;
}
 
Example 2
Source File: LegacyTransientValueService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
	if (feature.isTransient())
		return ValueTransient.YES;
	boolean isSet = semanticObject.eIsSet(feature);
	if (defaultValueIsSerializeable(feature) && !isSet)
		return ValueTransient.PREFERABLY;
	if (legacy.isTransient(semanticObject, feature, 0))
		return ValueTransient.YES;
	return isSet ? ValueTransient.NO : ValueTransient.YES;
}
 
Example 3
Source File: TransientValueService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ListTransient isListTransient(EObject semanticObject, EStructuralFeature feature) {
	if (feature.isTransient() || isContainerReferenceInSameResource(semanticObject, feature))
		return ListTransient.YES;
	else
		return ListTransient.NO;
}
 
Example 4
Source File: TransientValueService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
	if (feature.isTransient() || !semanticObject.eIsSet(feature)
			|| isContainerReferenceInSameResource(semanticObject, feature)) {
		if (defaultValueIsSerializeable(feature))
			return ValueTransient.PREFERABLY;
		else
			return ValueTransient.YES;
	} else
		return ValueTransient.NO;
}
 
Example 5
Source File: ForwardConverter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether a certain feature should be ignored during conversion.
 */
protected boolean ignore(EStructuralFeature feature) {
	if (feature.isTransient()) {
		if (feature instanceof EReference) {
			final EReference reference = (EReference) feature;
			if (reference.getEOpposite() != null
				&& !reference.getEOpposite().isTransient()) {
				return false;
			}
		}
		return true;
	}
	return false;
}
 
Example 6
Source File: BackwardConverter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether a certain feature should be ignored during conversion.
 */
protected boolean ignore(EStructuralFeature feature) {
    return feature.isTransient()
            || !feature.isChangeable()
            ||
            // according to
            // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf
            // the following three references need to be ignored
            EcorePackage.eINSTANCE.getEClass_ESuperTypes().equals(feature)
            || EcorePackage.eINSTANCE.getETypedElement_EType().equals(
                    feature)
            || EcorePackage.eINSTANCE.getEOperation_EExceptions().equals(
                    feature);
}
 
Example 7
Source File: DefaultTransientValueService.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean isTransient(EObject owner, EStructuralFeature feature, int index) {
	return feature.isTransient() || !owner.eIsSet(feature) || isContainerReferenceInSameResource(owner, feature);
}
 
Example 8
Source File: Ecore2XtextExtensions.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean needsAssignment(final EStructuralFeature it) {
  return ((((!it.isDerived()) && (!it.isTransient())) && (!((it instanceof EReference) && EReference.class.cast(it).isContainer()))) && 
    (!((it.getEType() instanceof EDataType) && (!EDataType.class.cast(it.getEType()).isSerializable()))));
}
 
Example 9
Source File: LazyLinkingResource.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Return <code>true</code> if the given feature may hold a proxy that has to be resolved.
 * 
 * This is supposed to be an internal hook which allows to resolve proxies even in cases
 * where EMF prohibits proxies, e.g. in case of opposite references.
 * 
 * @since 2.4
 */
protected boolean isPotentialLazyCrossReference(EStructuralFeature feature) {
	return !feature.isDerived() && !feature.isTransient() 
			&& feature instanceof EReference && ((EReference)feature).isResolveProxies();
}