Class ModelObjectCopier.CopyContext

  • Direct Known Subclasses:
    AttachingModelObjectCopier.SharedCopyContext
    Enclosing class:
    ModelObjectCopier

    public static class ModelObjectCopier.CopyContext
    extends Object
    Copy process context that holds information about copied objects, references, external properties names, etc. Context is passed through all copy methods to share state between them.

    Copy context is stateful and not safe for use by multiple threads.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.emf.ecore.EObject>> copiedExternalReferences  
      protected Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> copiedExternalResouces  
      protected Map<org.eclipse.emf.ecore.EClass,​List<String>> copiedNames  
      protected List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​Object>> copiedReferences  
      protected Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> copies  
    • Constructor Summary

      Constructors 
      Constructor Description
      CopyContext()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCopy​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject copy)
      Add copy to the context.
      void addCreatedName​(org.eclipse.emf.ecore.EClass eClass, String name)
      Add created unique name to the context.
      void addExternalReference​(org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, org.eclipse.emf.ecore.EObject externalProperty)
      Add created external reference to the context.
      void addExternalResource​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject copy)
      Add external resource copy objects to the context.
      void addReference​(org.eclipse.emf.ecore.EObject toObject, org.eclipse.emf.ecore.EReference toReference, Object value)
      Add created reference to the context.
      List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.emf.ecore.EObject>> getCopiedExternalReferences()
      Returns all context copied external references as triples: the external reference owner object.
      List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​Object>> getCopiedReferences()
      Returns all context copied references as triples: the reference owner object.
      Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> getCopies()
      Returns map of all context copies: original to its copy.
      List<String> getCreatedNames​(org.eclipse.emf.ecore.EClass eClass)
      Returns created names for the provided model EClass.
      Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> getExternalResources()
      Returns map of all context object with external resource copies: original to its copy.
    • Field Detail

      • copies

        protected Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> copies
      • copiedNames

        protected Map<org.eclipse.emf.ecore.EClass,​List<String>> copiedNames
      • copiedExternalResouces

        protected Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> copiedExternalResouces
      • copiedExternalReferences

        protected List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.emf.ecore.EObject>> copiedExternalReferences
      • copiedReferences

        protected List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​Object>> copiedReferences
    • Constructor Detail

      • CopyContext

        public CopyContext()
    • Method Detail

      • addCopy

        public void addCopy​(org.eclipse.emf.ecore.EObject source,
                            org.eclipse.emf.ecore.EObject copy)
        Add copy to the context.
        Parameters:
        source - the source object, cannot be null
        copy - the copy object, cannot be null
      • addCreatedName

        public void addCreatedName​(org.eclipse.emf.ecore.EClass eClass,
                                   String name)
        Add created unique name to the context.
        Parameters:
        eClass - the created class, cannot be null
        name - the created name, cannot be null
      • addReference

        public void addReference​(org.eclipse.emf.ecore.EObject toObject,
                                 org.eclipse.emf.ecore.EReference toReference,
                                 Object value)
        Add created reference to the context.
        Parameters:
        toObject - the reference owner object, cannot be null
        toReference - the reference feature, cannot be null
        value - the reference value, must be EObject or a collection of EObject, cannot be null
      • addExternalReference

        public void addExternalReference​(org.eclipse.emf.ecore.EObject toObject,
                                         org.eclipse.emf.ecore.EReference toReference,
                                         org.eclipse.emf.ecore.EObject externalProperty)
        Add created external reference to the context.
        Parameters:
        toObject - the external reference owner object, cannot be null
        toReference - the external reference feature, cannot be null
        externalProperty - the external reference, cannot be null
      • addExternalResource

        public void addExternalResource​(org.eclipse.emf.ecore.EObject source,
                                        org.eclipse.emf.ecore.EObject copy)
        Add external resource copy objects to the context.
        Parameters:
        source - the source external resource object, cannot be null
        copy - the copy external resource object, cannot be null
      • getCopiedExternalReferences

        public List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.emf.ecore.EObject>> getCopiedExternalReferences()
        Returns all context copied external references as triples:
        1. the external reference owner object.
        2. the external reference feature.
        3. the external reference.
        Returns:
        all context copied external references, never null
      • getCopiedReferences

        public List<org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​Object>> getCopiedReferences()
        Returns all context copied references as triples:
        1. the reference owner object.
        2. the reference feature.
        3. the reference value, EObject or a collection of EObject.
        Returns:
        all context copied external references, never null
      • getCopies

        public Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> getCopies()
        Returns map of all context copies: original to its copy.
        Returns:
        a map of all context copies: original to its copy, never null
      • getCreatedNames

        public List<String> getCreatedNames​(org.eclipse.emf.ecore.EClass eClass)
        Returns created names for the provided model EClass.
        Parameters:
        eClass - the created class, cannot be null
        Returns:
        a list of created names for the provided model EClass, never null
      • getExternalResources

        public Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EObject> getExternalResources()
        Returns map of all context object with external resource copies: original to its copy.
        Returns:
        a map of all context object with external resource copies: original to its copy, never null