Class ReferenceUtil


  • public final class ReferenceUtil
    extends Object
    This utility class holds methods that will be used by the diff and merge processes. TODO: Maybe useless.
    • Method Detail

      • getAsList

        public static List<Object> getAsList​(EObject object,
                                             EStructuralFeature feature)
        This utility simply allows us to retrieve the value of a given feature as a List.
        Parameters:
        object - The object for which feature we need a value.
        feature - The actual feature of which we need the value.
        Returns:
        The value of the given feature for the given object as a list. An empty list if this object has no value for that feature or if the object is null.
      • getAsListResolving

        public static List<Object> getAsListResolving​(EObject object,
                                                      EStructuralFeature feature)
        This utility simply allows us to retrieve the value of a given feature as a List.

        Note that contrary to getAsList(EObject, EStructuralFeature), this will allow proxy resolution.

        Parameters:
        object - The object for which feature we need a value.
        feature - The actual feature of which we need the value.
        Returns:
        The value of the given feature for the given object as a list. An empty list if this object has no value for that feature or if the object is null.
      • safeEGet

        public static Object safeEGet​(EObject object,
                                      EStructuralFeature feature)
        In case of dynamic EObjects, the EClasses of both sides might be different, making "eget" fail in "unknown feature". We assume that even if the EClasses are distinct instances, they are the same nonetheless, and thus we can use the feature name in order to retrieve the feature's value.
        Parameters:
        object - The object for which feature we need a value, must not be null.
        feature - The actual feature of which we need the value, must not be null.
        Returns:
        The value of the given feature for the given object.
      • safeResolvingEGet

        public static Object safeResolvingEGet​(EObject object,
                                               EStructuralFeature feature)
        In case of dynamic EObjects, the EClasses of both sides might be different, making "eget" fail in "unknown feature". We assume that even if the EClasses are distinct instances, they are the same nonetheless, and thus we can use the feature name in order to retrieve the feature's value.

        Note that contrary to safeEGet(EObject, EStructuralFeature), this will allow proxy resolution.

        Parameters:
        object - The object for which feature we need a value, must not be null.
        feature - The actual feature of which we need the value, must not be null.
        Returns:
        The value of the given feature for the given object.
      • safeEIsSet

        public static boolean safeEIsSet​(EObject object,
                                         EStructuralFeature feature)
        In case of dynamic EObjects, the EClasses of both sides might be different, making "isset" fail in "unknown feature". We assume that even if the EClasses are distinct instances, they are the same nonetheless, and thus we can use the feature name in order to retrieve the feature's value.
        Parameters:
        object - The object for which feature we need a value, must not be null.
        feature - The actual feature of which we need the value, must not be null.
        Returns:
        whether the feature for the given object is set.
      • safeESet

        public static void safeESet​(EObject object,
                                    EStructuralFeature feature,
                                    Object newValue)
        In case of dynamic EObjects, the EClasses of both sides might be different, making "isset" fail in "unknown feature". We assume that even if the EClasses are distinct instances, they are the same nonetheless, and thus we can use the feature name in order to retrieve the feature's value.
        Parameters:
        object - The object for which feature we'll set the value, must not be null.
        feature - The actual feature of which we'll set the value, must not be null.
        newValue - The value to set, can be null.
      • isFeatureMapDerivedFeature

        public static boolean isFeatureMapDerivedFeature​(EReference reference)
        Checks if the given reference is a FeatureMap-derived feature.
        Parameters:
        reference - the given EReference.
        Returns:
        true if the given reference is a FeatureMap-derived feature, false otherwise.
        Since:
        3.2