org.eclipse.emf.emfstore.modelmutator
Class ESAbstractModelMutator

java.lang.Object
  extended by org.eclipse.emf.emfstore.modelmutator.ESAbstractModelMutator
Direct Known Subclasses:
ESCrossResourceReferencesModelMutator, ESDefaultModelMutator

public abstract class ESAbstractModelMutator
extends Object

Abstract implementation of an model mutator.

Since:
2.0
Author:
Julian Sommerfeldt

Constructor Summary
ESAbstractModelMutator()
          Default constructor.
ESAbstractModelMutator(ESModelMutatorConfiguration config)
          Constructor.
 
Method Summary
 void changeCrossReferences()
          Changes cross references of all EObjects in the model.
 void changeCrossReferences(org.eclipse.emf.ecore.EObject obj)
          Changes CrossReferences of an specific EObject.
 List<org.eclipse.emf.ecore.EObject> createChildren(org.eclipse.emf.ecore.EObject root)
          Creates/deletes direct children for the given EObject.
 boolean createChildren(org.eclipse.emf.ecore.EObject root, int depth)
          Create recursively direct and indirect children for a given EObject and its children.
 void createChildrenForRoot()
          Create the children for the root object.
 void deleteEObjects(org.eclipse.emf.ecore.EObject root)
          Randomly deletes direct and indirect children of the given root EObject.
 void generate()
          Initial generation.
 ESModelMutatorConfiguration getConfig()
           
 void mutate(Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
          Mutation after an initial generation.
 void mutateAttributes(Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
          Randomly mutates all attributes.
 void mutateUntil(com.google.common.base.Predicate<org.eclipse.emf.ecore.EObject> predicate)
          Performs mutation until the given Predicate is met.
abstract  void postMutate()
          Called after generation and mutation.
abstract  void preMutate()
          Called before generation and mutation.
 void setConfig(ESModelMutatorConfiguration config)
          Sets the config to be used by the mutator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ESAbstractModelMutator

public ESAbstractModelMutator()
Default constructor. Leaves the config uninitialized.


ESAbstractModelMutator

public ESAbstractModelMutator(ESModelMutatorConfiguration config)
Constructor.

Parameters:
config - The ESModelMutatorConfiguration to use for mutation.
Method Detail

preMutate

public abstract void preMutate()
Called before generation and mutation.


postMutate

public abstract void postMutate()
Called after generation and mutation.


generate

public void generate()
Initial generation.


mutate

public void mutate(Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
Mutation after an initial generation.

Parameters:
ignoredFeatures - a set of features to be ignored while mutating

mutateUntil

public void mutateUntil(com.google.common.base.Predicate<org.eclipse.emf.ecore.EObject> predicate)
Performs mutation until the given Predicate is met. The predicate input will be the the root object obtained by calling getConfig().

Parameters:
predicate - the predicate that must be fulfilled in order to stop mutation

createChildrenForRoot

public void createChildrenForRoot()
Create the children for the root object.


createChildren

public boolean createChildren(org.eclipse.emf.ecore.EObject root,
                              int depth)
Create recursively direct and indirect children for a given EObject and its children.

Parameters:
root - The EObject for which children should be generated.
depth - The depth of the EObject in the total tree.
Returns:
true, if children have been created, false otherwise

createChildren

public List<org.eclipse.emf.ecore.EObject> createChildren(org.eclipse.emf.ecore.EObject root)
Creates/deletes direct children for the given EObject.

Parameters:
root - The EObject for which children should be created.
Returns:
A list of the newly generated children

deleteEObjects

public void deleteEObjects(org.eclipse.emf.ecore.EObject root)
Randomly deletes direct and indirect children of the given root EObject.

Parameters:
root - The EObject from which children should be deleted.

mutateAttributes

public void mutateAttributes(Set<org.eclipse.emf.ecore.EStructuralFeature> ignoredFeatures)
Randomly mutates all attributes.

Parameters:
ignoredFeatures - a set of features to be ignored while mutating

changeCrossReferences

public void changeCrossReferences()
Changes cross references of all EObjects in the model.


changeCrossReferences

public void changeCrossReferences(org.eclipse.emf.ecore.EObject obj)
Changes CrossReferences of an specific EObject.

Parameters:
obj - The EObject whose cross references should be changed

getConfig

public ESModelMutatorConfiguration getConfig()
Returns:
the modelMutatorConfig

setConfig

public void setConfig(ESModelMutatorConfiguration config)
Sets the config to be used by the mutator.

Parameters:
config - the config to be used by the mutator


Copyright © 2015. All Rights Reserved.