|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.emfstore.modelmutator.ESModelMutatorUtil
public final class ESModelMutatorUtil
Util class for the ModelMutator.
Field Summary | |
---|---|
static int |
DELETE_CUT_CONTAINMENT
Indicates deleting through removing containment references. |
static int |
DELETE_DELETE_COMMAND
Indicates deleting with the DeleteCommand . |
static int |
DELETE_ECORE
Indicates deleting with the EcoreUtil.delete(EObject) method. |
Constructor Summary | |
---|---|
ESModelMutatorUtil(ESModelMutatorConfiguration config)
A new ESModelMutatorUtil . |
Method Summary | |
---|---|
void |
addedEObject(org.eclipse.emf.ecore.EObject addedEObject)
Notifies this util that a new object has been added to maintain the index of offering and suitable objects. |
void |
addPerCommand(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Collection<?> objects)
Adds all objects to the many-valued feature of eObject using an AddCommand. |
void |
addPerCommand(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Object newValue,
Integer index)
Adds newValue to the many-valued feature of eObject using an AddCommand. |
static boolean |
canHaveInstance(org.eclipse.emf.ecore.EClass eClass)
Returns whether eClass can be instantiated or not. |
Object |
createNewAttribute(org.eclipse.emf.ecore.EAttribute eAttribute)
Creates a random attribute value for the given EAttribute . |
org.eclipse.emf.ecore.EObject |
createOfType(org.eclipse.emf.ecore.EClass eClass)
|
void |
deletedEObject(org.eclipse.emf.ecore.EObject deletedEObject)
Notifies this util that an object has been deleted to maintain the index of offering and suitable objects. |
static Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> |
getAllClassesAndObjects(org.eclipse.emf.ecore.EObject rootObject)
Returns all direct and indirect contents of rootObject as a
map. |
List<org.eclipse.emf.ecore.EClass> |
getAllEClasses()
Iterates over all registered EPackages in order to retrieve all available EClasses, excluding abstract classes and interfaces, and returns them as a Set. |
List<org.eclipse.emf.ecore.EClass> |
getAllEClasses(Collection<org.eclipse.emf.ecore.EPackage> ePackages)
Get all EClass es in the EPackage s. |
List<org.eclipse.emf.ecore.EClass> |
getAllEClasses(org.eclipse.emf.ecore.EPackage ePackage)
Retrieve all EClasses that are contained in ePackage . |
List<org.eclipse.emf.ecore.EClass> |
getAllEContainments(org.eclipse.emf.ecore.EReference reference)
Get all containments of a reference. |
static Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> |
getAllObjects(org.eclipse.emf.ecore.EObject root)
Returns all contents of the given EObject sorted by
the EClass of the contained children. |
static int |
getAllObjectsCount(org.eclipse.emf.ecore.EObject obj)
|
List<org.eclipse.emf.ecore.EClass> |
getAllSubEClasses(org.eclipse.emf.ecore.EClass eClass)
Returns all subclasses of an EClass, excluding abstract classes and interfaces. |
Map<org.eclipse.emf.ecore.EClassifier,AttributeSetter<?>> |
getAttributeSetters()
Returns a map containing an AttributeSetter-instance for each attribute type, granting access to all AttributeSetters. |
Iterable<org.eclipse.emf.ecore.EStructuralFeature> |
getAvailableFeatures()
Returns the features that are currently available for mutation. |
Iterable<org.eclipse.emf.ecore.EStructuralFeature> |
getAvailableFeatures(com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EStructuralFeature> predicate)
Returns the features that are currently available for mutation filtered by the given predicate . |
List<Integer> |
getDeleteModes()
Returns the delete modes. |
static org.eclipse.emf.ecore.EPackage |
getEPackage(String nsURI)
Returns the EPackage to the specified nsURI . |
ESModelMutatorConfiguration |
getModelMutatorConfiguration()
Returns the model mutator configuration. |
Iterable<org.eclipse.emf.ecore.EObject> |
getOfferingEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns the currently existing objects to be mutated that offer the given feature . |
Iterable<org.eclipse.emf.ecore.EObject> |
getOfferingEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature,
com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EObject> predicate)
Returns the currently existing objects to be mutated that offer the given feature filtered by the given
predicate . |
int |
getRandomDeleteMode()
Returns a random delete mode. |
Set<org.eclipse.emf.ecore.EClass> |
getReferenceClasses(org.eclipse.emf.ecore.EReference reference,
Set<org.eclipse.emf.ecore.EClass> allEClasses)
Retrieves all EClasses from allEClasses that can possibly be
referenced by reference and returns them as a set. |
Iterable<org.eclipse.emf.ecore.EObject> |
getSuitableEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns currently existing objects that are suitable to act as values for the given feature filtered by
the given predicate . |
Iterable<org.eclipse.emf.ecore.EObject> |
getSuitableEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature,
com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EObject> predicate)
Returns currently existing objects that are suitable to act as values for the given feature . |
List<org.eclipse.emf.ecore.EReference> |
getValidContainmentReferences(org.eclipse.emf.ecore.EObject eObject)
Returns all valid containment references for an EObject. |
List<org.eclipse.emf.ecore.EReference> |
getValidCrossReferences(org.eclipse.emf.ecore.EObject eObject)
Returns all valid references for an EObject. |
boolean |
isUniqueID(Object id)
|
boolean |
isValid(org.eclipse.emf.ecore.EStructuralFeature feature,
org.eclipse.emf.ecore.EObject eObject)
Returns whether an EStructuralFeature is valid for an EObject or not. |
void |
movePerCommand(org.eclipse.emf.ecore.EObject parent,
org.eclipse.emf.ecore.EStructuralFeature feature,
Object objectToMove,
Integer index)
Move an object. |
void |
registerID(Object id)
|
void |
removeFullPerCommand(org.eclipse.emf.ecore.EObject eObject,
int howToDelete)
Deletes the EObject using the specified howToDelete . |
void |
removePerCommand(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Collection<?> objects)
Removes objects from a feature of eObject using
a RemoveCommand. |
void |
setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject)
Sets all possible attributes of known types to random values using AttributeSetter and
SetCommands/AddCommands. |
void |
setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject,
int maxNumber,
Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
Sets all possible attributes of known types to random values using AttributeSetter and
SetCommands/AddCommands. |
void |
setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject,
Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
Sets all possible attributes of known types to random values using AttributeSetter and
SetCommands/AddCommands. |
org.eclipse.emf.ecore.EObject |
setPerCommand(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Object newValue)
Sets a feature between eObject and newValue using a SetCommand. |
org.eclipse.emf.ecore.EObject |
setPerCommand(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Object newValue,
Integer index)
Sets a feature between eObject and newValue using a SetCommand. |
void |
setReference(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EClass referenceClass,
org.eclipse.emf.ecore.EReference reference,
Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> allEObjects)
Sets or adds to a reference for an EObject with any generated instance of referenceClass using
SetCommand/AddCommand. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DELETE_DELETE_COMMAND
DeleteCommand
.
public static final int DELETE_CUT_CONTAINMENT
public static final int DELETE_ECORE
EcoreUtil.delete(EObject)
method.
Constructor Detail |
---|
public ESModelMutatorUtil(ESModelMutatorConfiguration config)
ESModelMutatorUtil
.
config
- The ESModelMutatorConfiguration
of the ESModelMutatorUtil
.Method Detail |
---|
public static org.eclipse.emf.ecore.EPackage getEPackage(String nsURI)
nsURI
.
nsURI
- the NsUri of the EPackage to get
nsURI
EPackage.Registry.getEPackage(String)
public List<org.eclipse.emf.ecore.EReference> getValidContainmentReferences(org.eclipse.emf.ecore.EObject eObject)
eObject
- the EObject to get references for
public List<org.eclipse.emf.ecore.EReference> getValidCrossReferences(org.eclipse.emf.ecore.EObject eObject)
eObject
- the EObject to get references for
public boolean isValid(org.eclipse.emf.ecore.EStructuralFeature feature, org.eclipse.emf.ecore.EObject eObject)
feature
- the EStructuralFeature in questioneObject
- the EObject to check the feature for
public List<org.eclipse.emf.ecore.EClass> getAllEContainments(org.eclipse.emf.ecore.EReference reference)
reference
- The EReference
for which to get all containments.
EReference
.public static boolean canHaveInstance(org.eclipse.emf.ecore.EClass eClass)
eClass
can be instantiated or not. An EClass
can be instantiated, if it is neither an interface nor abstract.
eClass
- the EClass in question
eClass
can be instantiated or not.public List<org.eclipse.emf.ecore.EClass> getAllSubEClasses(org.eclipse.emf.ecore.EClass eClass)
eClass
- the EClass to get subclasses for
eClass
public List<org.eclipse.emf.ecore.EClass> getAllEClasses()
EPackage.Registry
public List<org.eclipse.emf.ecore.EClass> getAllEClasses(Collection<org.eclipse.emf.ecore.EPackage> ePackages)
EClass
es in the EPackage
s.
ePackages
- The EPackage
s containg the EClass
es.
EClass
es contained in the EPackage
s.public List<org.eclipse.emf.ecore.EClass> getAllEClasses(org.eclipse.emf.ecore.EPackage ePackage)
ePackage
.
ePackage
- the package to get contained EClasses from
ePackage
public static Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> getAllClassesAndObjects(org.eclipse.emf.ecore.EObject rootObject)
rootObject
as a
map. All EObjects that appear in these contents are mapped to their
corresponding EClass.
rootObject
- the EObject to get contents for
public void addPerCommand(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Object newValue, Integer index)
newValue
to the many-valued feature of eObject
using an AddCommand. Exceptions are
caught if ignoreAndLog
is true, otherwise a RuntimeException might be
thrown if the command fails.
eObject
- the EObject to which newObject
shall be addedfeature
- the EStructuralFeature that newObject
shall be added tonewValue
- the Object that shall be added to feature
index
- the index where to add the object or null if it should be added to the end.AddCommand.AddCommand(EditingDomain, EObject, EStructuralFeature, Object)
public void addPerCommand(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Collection<?> objects)
objects
to the many-valued feature of eObject
using an AddCommand. Exceptions
are caught if ignoreAndLog
is true, otherwise a RuntimeException might be
thrown if the command fails.
eObject
- the EObject to which objects
shall be addedfeature
- the EReference that objects
shall be added toobjects
- collection of objects that shall be added to feature
public void movePerCommand(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EStructuralFeature feature, Object objectToMove, Integer index)
parent
- The parent object.feature
- The feature of the parent object.objectToMove
- The object to move within the parents feature.index
- The index where to move the object to.public org.eclipse.emf.ecore.EObject setPerCommand(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Object newValue, Integer index)
eObject
and newValue
using a SetCommand. Exceptions are caught
if ignoreAndLog
is
true, otherwise a RuntimeException might be thrown if the command fails.
eObject
- the EObject for which feature
shall be setfeature
- the EStructuralFeature that shall be setnewValue
- the Object that shall be set as a feature in parentEObject
index
- Where to set to object to or null if it should be set to the end.
newValue
if the SetCommand
was performed successful or null
if it
failedSetCommand
public org.eclipse.emf.ecore.EObject setPerCommand(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Object newValue)
eObject
and newValue
using a SetCommand. Exceptions are caught
if ignoreAndLog
is
true, otherwise a RuntimeException might be thrown if the command fails.
eObject
- the EObject for which feature
shall be setfeature
- the EStructuralFeature that shall be setnewValue
- the Object that shall be set as a feature in parentEObject
newValue
if the SetCommand
was
performed successful or null
if it failedSetCommand
public void removePerCommand(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Collection<?> objects)
objects
from a feature of eObject
using
a RemoveCommand. Exceptions are caught if ignoreAndLog
is
true, otherwise a RuntimeException might be thrown if the command fails.
eObject
- the EObject to remove objects
fromfeature
- the EStructuralFeature objects
shall be removed
fromobjects
- collection of Objects that shall be removedRemoveCommand
public void removeFullPerCommand(org.eclipse.emf.ecore.EObject eObject, int howToDelete)
EObject
using the specified howToDelete
.
eObject
- The EObject
to delete.howToDelete
- The way to delete: DELETE_ECORE
, DELETE_DELETE_COMMAND
or
DELETE_CUT_CONTAINMENT
.public void setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject)
AttributeSetter
and
SetCommands/AddCommands.
eObject
- the EObject to set attributes forAttributeSetter
public void setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject, int maxNumber, Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
AttributeSetter
and
SetCommands/AddCommands.
eObject
- the EObject to set attributes formaxNumber
- the maximal number of attributes to mutateignoredFeatures
- a set of attributes to be ignoredAttributeSetter
public org.eclipse.emf.ecore.EObject createOfType(org.eclipse.emf.ecore.EClass eClass)
public static Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> getAllObjects(org.eclipse.emf.ecore.EObject root)
EObject
sorted by
the EClass
of the contained children.
root
- The root object containing the direct and indirect children.
public Map<org.eclipse.emf.ecore.EClassifier,AttributeSetter<?>> getAttributeSetters()
AttributeSetter
public Object createNewAttribute(org.eclipse.emf.ecore.EAttribute eAttribute)
EAttribute
.
eAttribute
- the attribute to create a new value for
public Set<org.eclipse.emf.ecore.EClass> getReferenceClasses(org.eclipse.emf.ecore.EReference reference, Set<org.eclipse.emf.ecore.EClass> allEClasses)
allEClasses
that can possibly be
referenced by reference
and returns them as a set.
reference
- the EReference to get EClasses forallEClasses
- set of all potentially possible EClasses
reference
public void setReference(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EClass referenceClass, org.eclipse.emf.ecore.EReference reference, Map<org.eclipse.emf.ecore.EClass,List<org.eclipse.emf.ecore.EObject>> allEObjects)
referenceClass
using
SetCommand/AddCommand. If the reference
is not required, random
decides whether the reference is set
or how many EObjects are added to it.
eObject
- the EObject to set the reference forreferenceClass
- the EClass all referenced EObject shall be instances ofreference
- the reference to setallEObjects
- Map containing all available EObjects mapped to their EClasses.addPerCommand(EObject, EStructuralFeature, Collection)
,
addPerCommand(EObject, EStructuralFeature, Object, Integer)
,
setPerCommand(EObject, EStructuralFeature, Object)
,
setPerCommand(EObject, EStructuralFeature, Object, Integer)
public static int getAllObjectsCount(org.eclipse.emf.ecore.EObject obj)
obj
- The root object containing the direct and indirect children.
public void setEObjectAttributes(org.eclipse.emf.ecore.EObject eObject, Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
AttributeSetter
and
SetCommands/AddCommands.
eObject
- the EObject to set attributes forignoredFeatures
- a set of attributes to be ignoredAttributeSetter
public ESModelMutatorConfiguration getModelMutatorConfiguration()
public Iterable<org.eclipse.emf.ecore.EStructuralFeature> getAvailableFeatures()
public Iterable<org.eclipse.emf.ecore.EStructuralFeature> getAvailableFeatures(com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EStructuralFeature> predicate)
predicate
.
predicate
- The predicate to be used for filtering the available features.
public Iterable<org.eclipse.emf.ecore.EObject> getOfferingEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
.
feature
- The feature to get existing objects for.
feature
.public Iterable<org.eclipse.emf.ecore.EObject> getOfferingEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature, com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EObject> predicate)
feature
filtered by the given
predicate
.
feature
- The feature to get existing objects for.predicate
- The predicate to be used for filtering the objects.
feature
.public Iterable<org.eclipse.emf.ecore.EObject> getSuitableEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
filtered by
the given predicate
.
feature
- The feature to get suitable objects for.
feature
.public Iterable<org.eclipse.emf.ecore.EObject> getSuitableEObjectsForAvailableFeature(org.eclipse.emf.ecore.EStructuralFeature feature, com.google.common.base.Predicate<? super org.eclipse.emf.ecore.EObject> predicate)
feature
.
feature
- The feature to get suitable objects for.predicate
- The predicate to be used for filtering the objects.
feature
.public void addedEObject(org.eclipse.emf.ecore.EObject addedEObject)
addedEObject
- The added object.public void deletedEObject(org.eclipse.emf.ecore.EObject deletedEObject)
deletedEObject
- The added object.public List<Integer> getDeleteModes()
public int getRandomDeleteMode()
public boolean isUniqueID(Object id)
id
- the ID to check for uniqueness
id
is unique, false otherwisepublic void registerID(Object id)
id
- the ID to register
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |