Class ConvertElementInfo

  • All Implemented Interfaces:
    java.lang.Comparable<ConvertElementInfo>

    @OpenApiAll
    public class ConvertElementInfo
    extends java.lang.Object
    implements java.lang.Comparable<ConvertElementInfo>
    Holds information which controls the process of element conversion, for example allows to define target element type and preferred symbol type.
    See Also:
    Refactoring, Element, PresentationElement
    • Field Detail

      • name

        @CheckForNull
        private final java.lang.String name
        Name of conversion, in most cases it is a name of target element type.
      • elementType

        private final java.lang.Class<? extends Element> elementType
        Type of the element to which element should be converted.
      • symbolType

        @CheckForNull
        private final java.lang.Class<? extends PresentationElement> symbolType
        Preferred type of symbol to which element should be converted.
      • createSymbol

        private boolean createSymbol
        Indicates if symbol should be created by this conversion.
      • canInfoBeLost

        private boolean canInfoBeLost
        Indicates if model information can be lost with the conversion.
      • convertOnlyIncomingReferences

        private boolean convertOnlyIncomingReferences
        Indicates if only incoming references should be converted. For example, if property has a type and it replaces another property, its type will be preserved, because it is an outgoing reference.
      • canChangeElementName

        private boolean canChangeElementName
        Indicates if conversion can change name of the element.
      • preserveElementID

        private boolean preserveElementID
        Indicates if element ID should be preserved during conversion. Be aware of leaving the source element id. There may be modules (not loaded/used by project) still referencing the source element (by id) and expecting the source element type. There should be no problems if source element is used only in current project.
      • elementIDSuffix

        private java.lang.String elementIDSuffix
        When preserving element id a suffix can be appended to the old element ID.
      • additionalStereotypes

        private java.util.Collection<Stereotype> additionalStereotypes
        Stereotypes to apply to converted element after conversion
      • convertRelatedElements

        private boolean convertRelatedElements
      • pendingMapping

        private java.util.Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> pendingMapping
    • Constructor Detail

      • ConvertElementInfo

        public ConvertElementInfo​(@CheckForNull
                                  java.lang.String name,
                                  java.lang.Class<? extends Element> elementType,
                                  @CheckForNull
                                  java.lang.Class<? extends PresentationElement> symbolType)
        Constructs this info.
        Parameters:
        name - name of conversion.
        elementType - type to which to convert.
        symbolType - preferred symbol type to which to convert.
      • ConvertElementInfo

        public ConvertElementInfo​(java.lang.Class<? extends Element> elementType,
                                  java.lang.Class<? extends PresentationElement> symbolType)
        Constructs this info.
        Parameters:
        elementType - type to which to convert.
        symbolType - preferred symbol type to which to convert.
      • ConvertElementInfo

        public ConvertElementInfo​(@CheckForNull
                                  java.lang.String name,
                                  java.lang.Class<? extends Element> elementType,
                                  boolean createSymbol)
        Constructs this info.
        Parameters:
        name - name of conversion.
        elementType - type to which to convert.
        createSymbol - indicates if symbol should be created with this conversion.
      • ConvertElementInfo

        public ConvertElementInfo​(java.lang.Class<? extends Element> elementType)
        Constructs this info.
        Parameters:
        elementType - type to which to convert.
      • ConvertElementInfo

        public ConvertElementInfo​(java.lang.Class<? extends Element> elementType,
                                  boolean canInfoBeLost)
        Constructs this info.
        Parameters:
        elementType - type to which to convert.
        canInfoBeLost - indicates if info can be lost by conversion.
    • Method Detail

      • getName

        @CheckForNull
        public java.lang.String getName()
        Gets name of conversion.
        Returns:
        name of conversion.
      • getElementType

        public java.lang.Class<? extends Element> getElementType()
        Gets type of the element to which to convert.
        Returns:
        type of the element to which to convert.
      • getSymbolType

        @CheckForNull
        public java.lang.Class<? extends PresentationElement> getSymbolType()
        Type of the symbol to which to convert.
        Returns:
        type of the symbol to which to convert.
      • getHumanName

        public java.lang.String getHumanName()
        Gets human-readable format of the conversion.
        Returns:
        human-readable format of the conversion.
      • isCreateSymbol

        public boolean isCreateSymbol()
        Gets create symbol flag value.
        Returns:
        create symbol flag value.
      • setCreateSymbol

        public void setCreateSymbol​(boolean createSymbol)
        Sets create symbol flag value.
        Parameters:
        createSymbol - create symbol flag value.
      • canInfoBeLost

        public boolean canInfoBeLost​(Element source)
        Indicates if info can be lost for a given source element.
        Parameters:
        source - element being converted.
        Returns:
        true if info can be lost, false otherwise.
      • setCanInfoBeLost

        public void setCanInfoBeLost​(boolean canInfoBeLost)
        Sets info can be lost flag value.
        Parameters:
        canInfoBeLost - info can be lost flag value.
      • canConvert

        public boolean canConvert​(Element element)
        Indicates if element can be converted.
        Parameters:
        element - element to convert.
        Returns:
        true if element can be converted, false otherwise.
      • isConvertingSourceEditable

        public boolean isConvertingSourceEditable​(Element source)
        Indicates if source element is editable
        Parameters:
        source - source to convert
        Returns:
        true if element is editable and can be converted, false otherwise.
      • isConvertOnlyIncomingReferences

        public boolean isConvertOnlyIncomingReferences()
        Gets convert only incoming references flag value.
        Returns:
        convert only incoming references flag value.
      • setConvertOnlyIncomingReferences

        public void setConvertOnlyIncomingReferences​(boolean convertOnlyIncomingReferences)
        Sets convert only incoming references flag value.
        Parameters:
        convertOnlyIncomingReferences - convert only incoming references flag value.
      • isDisposeSource

        public boolean isDisposeSource()
        Indicates if source should be disposed after conversion.
        Returns:
        true if source should be disposed, false otherwise.
      • isCanChangeElementName

        public boolean isCanChangeElementName()
        Gets can change element name flag value.
        Returns:
        can change element name flag value.
      • setCanChangeElementName

        public void setCanChangeElementName​(boolean canChangeElementName)
        Sets can change element name flag value.
        Parameters:
        canChangeElementName - can change element name flag value.
      • canChangeElement

        public boolean canChangeElement​(Element element)
        Indicates if element can be changed by conversion.
        Parameters:
        element - element being converted.
        Returns:
        true if element can be changed by conversion.
      • isPreserveElementID

        public boolean isPreserveElementID()
        Gets preserve element ID flag value.
        Returns:
        preserve element ID flag value
      • setPreserveElementID

        @Deprecated
        public void setPreserveElementID​(boolean preserveElementID)
        Deprecated.
        it is not recommended to use this setting as preserving ids can break model consistency if some situations
        Sets preserve element ID flag value.
        Parameters:
        preserveElementID - preserve element ID flag value
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • setCategory

        public void setCategory​(ConvertElementInfoCategory category)
        Set category of info used for grouping of targets in UI.
        Parameters:
        category - category
      • getElementIDSuffix

        public java.lang.String getElementIDSuffix()
        Gets element ID suffix.
        Returns:
        element ID suffix.
      • setElementIDSuffix

        public void setElementIDSuffix​(java.lang.String elementIDSuffix)
        Sets element ID suffix.
        Parameters:
        elementIDSuffix - suffix to set.
      • isRemoveFromCollections

        public boolean isRemoveFromCollections()
        If the method returns true then convert should remove a value from the source element collection. Default implementation does not remove the collections.
        Returns:
        false.
      • setAdditionalStereotypes

        public void setAdditionalStereotypes​(@Nonnull
                                             java.util.Collection<Stereotype> stereotypes)
        Set stereotypes to apply to converted element after conversion
        Parameters:
        stereotypes - stereotypes
      • getAdditionalStereotypes

        public java.util.Collection<Stereotype> getAdditionalStereotypes()
        Returns:
        some stereotypes to apply to converted element after conversion
      • setDisposeSourceValidator

        public void setDisposeSourceValidator​(ConvertElementInfo.DisposeSourceValidator disposeSourceValidator)
        Sets dispose source validator.
        Parameters:
        disposeSourceValidator - dispose source validator to set.
      • isConvertRelatedElements

        public boolean isConvertRelatedElements()
        Returns:
        true if related elements should be converted also. Default is true
      • setConvertRelatedElements

        public void setConvertRelatedElements​(boolean convertRelatedElements)
        Set flag for related elements converting
        Parameters:
        convertRelatedElements - convert related elements
      • getPendingMapping

        @CheckForNull
        public java.util.Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> getPendingMapping()
        Returns:
        mapping for other elements that will be converted later
      • setPendingMapping

        public void setPendingMapping​(java.util.Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> pendingMapping)
        Sets mapping for elements which will be converted later
        Parameters:
        pendingMapping - mapping of elements will be done later