Class EmgOperationContributor
- java.lang.Object
-
- org.eclipse.epsilon.eol.execute.operations.contributors.OperationContributor
-
- org.eclipse.epsilon.emg.execute.operations.contributors.EmgOperationContributor
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.commons.math3.random.RandomGenerator
,IEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
public class EmgOperationContributor extends OperationContributor implements IEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
The Class ObjectOperationContributor delegates all the random generating functions to a EmgRandomGenerator but overloads the nextXXXList operations to allow the user to specify @list annotations values as listIDs.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.epsilon.emg.random.IEmgRandomGenerator
IEmgRandomGenerator.DefaultCharacterSet, IEmgRandomGenerator.Distribution
-
-
Field Summary
-
Fields inherited from class org.eclipse.epsilon.eol.execute.operations.contributors.OperationContributor
cachedMethodNames
-
-
Constructor Summary
Constructors Constructor Description EmgOperationContributor(EmgModule module)
Instantiates a new emg operation contributor.EmgOperationContributor(EmgModule module, long seed)
Instantiates a new emg operation contributor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contributesTo(Object target)
long[]
decode(String hash)
Decode string to numbers.String
encode(int number)
Encrypt numbers to string.String
getHasids_salt()
Gets the hasids salt.Collection<Object>
getNamedList(String name)
Gets the elements from create rules with the @list annotation with the given name parameter.List<Integer>
nextAddTo(int n, int m)
Returns an array of n integers that addvar to m.double
nextBinomialValue(int numberOfTrials, double probabilityOfSuccess)
Next binomial value.boolean
nextBoolean()
void
nextBytes(byte[] bytes)
String
nextCamelCaseString(int length, int minWordLength)
Next camel case string.String
nextCapitalisedString(String charSet, int length)
Next capitalised string.double
nextDobule(double upper)
Next dobule.double
nextDobule(double lower, double upper)
Next dobule.double
nextDouble()
double
nextExponentialValue(double mean)
Next exponential value.float
nextFloat()
Object
nextFromCollection(Collection<?> c)
Next from collection.Object
nextFromList(String listID)
The listID is the value of a @list annotation of a create operation.Object
nextFromListAsSample(String listID)
The listID is the value of a @list annotation of a create operation.double
nextGaussian()
String
nextHttpURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)
Next http URI.int
nextInt()
int
nextInt(int n)
int
nextInteger(int upper)
Next integer.int
nextInteger(int lower, int upper)
Next integer.long
nextLong()
long
nextLong(long upper)
Next long.long
nextLong(long lower, long upper)
Next long.List<Object>
nextSample(String listID, int k)
The listID is the value of a @list annotation of a create operation.List<Object>
nextSample(Collection<?> c, int k)
Next sample.String
nextString(String charSet, int length)
Next string.String
nextURI()
Next URI.String
nextURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)
Next URI.double
nextValue()
Next value.void
setHasids_salt(String hasids_salt)
Sets the hasids salt.void
setSeed(int seed)
void
setSeed(int[] seed)
void
setSeed(long seed)
void
useBinomialDistribution(int numberOfTrials, double probabilityOfSuccess)
Use binomial distribution.void
useExponentialDistribution(double mean)
Use exponential distribution.-
Methods inherited from class org.eclipse.epsilon.eol.execute.operations.contributors.OperationContributor
close, findContributedMethodForEvaluatedParameters, findContributedMethodForEvaluatedParameters, findContributedMethodForUnevaluatedParameters, getContext, getReflectionTarget, getTarget, includeInheritedMethods, setContext, setTarget
-
-
-
-
Constructor Detail
-
EmgOperationContributor
public EmgOperationContributor(EmgModule module)
Instantiates a new emg operation contributor.- Parameters:
module
- the module
-
EmgOperationContributor
public EmgOperationContributor(EmgModule module, long seed)
Instantiates a new emg operation contributor.- Parameters:
module
- the moduleseed
- the seed
-
-
Method Detail
-
contributesTo
public boolean contributesTo(Object target)
- Specified by:
contributesTo
in classOperationContributor
-
decode
public long[] decode(String hash)
Decode string to numbers.- Parameters:
hash
- the encrypt string- Returns:
- decoded numbers
-
encode
public String encode(int number)
Encrypt numbers to string.- Parameters:
number
- the number- Returns:
- the encrypt string
-
getHasids_salt
public String getHasids_salt()
Gets the hasids salt.- Returns:
- the hasids_salt
-
getNamedList
public Collection<Object> getNamedList(String name)
Gets the elements from create rules with the @list annotation with the given name parameter.- Parameters:
name
- the name- Returns:
- the named list
-
nextAddTo
public List<Integer> nextAddTo(int n, int m) throws EolRuntimeException
Description copied from interface:IEmgRandomGenerator
Returns an array of n integers that addvar to m.- Specified by:
nextAddTo
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Returns:
- Throws:
EolRuntimeException
-
nextBinomialValue
public double nextBinomialValue(int numberOfTrials, double probabilityOfSuccess)
Next binomial value.- Specified by:
nextBinomialValue
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
numberOfTrials
- the number of trialsprobabilityOfSuccess
- the probability of success- Returns:
- the double
- See Also:
EmgRandomGenerator.nextBinomialValue(int, double)
-
nextBoolean
public boolean nextBoolean()
- Specified by:
nextBoolean
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextBoolean()
-
nextBytes
public void nextBytes(byte[] bytes)
- Specified by:
nextBytes
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Parameters:
bytes
-- See Also:
EmgRandomGenerator.nextBytes(byte[])
-
nextCamelCaseString
public String nextCamelCaseString(int length, int minWordLength) throws EolRuntimeException
Next camel case string.- Specified by:
nextCamelCaseString
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
length
- the lengthminWordLength
- the min word length- Returns:
- the string
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextCamelCaseString(int, int)
-
nextCapitalisedString
public String nextCapitalisedString(String charSet, int length)
Next capitalised string.- Specified by:
nextCapitalisedString
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
charSet
- the char setlength
- the length- Returns:
- the string
- See Also:
EmgRandomGenerator.nextCapitalisedString(java.lang.String, int)
-
nextDobule
public double nextDobule(double upper) throws EolRuntimeException
Next dobule.- Specified by:
nextDobule
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
upper
- the upper- Returns:
- the double
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextDobule(double)
-
nextDobule
public double nextDobule(double lower, double upper)
Next dobule.- Specified by:
nextDobule
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
lower
- the lowerupper
- the upper- Returns:
- the double
- See Also:
EmgRandomGenerator.nextDobule(double, double)
-
nextDouble
public double nextDouble()
- Specified by:
nextDouble
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextDouble()
-
nextExponentialValue
public double nextExponentialValue(double mean)
Next exponential value.- Specified by:
nextExponentialValue
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
mean
- the mean- Returns:
- the double
- See Also:
EmgRandomGenerator.nextExponentialValue(double)
-
nextFloat
public float nextFloat()
- Specified by:
nextFloat
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextFloat()
-
nextFromCollection
public Object nextFromCollection(Collection<?> c)
Next from collection.- Specified by:
nextFromCollection
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
c
- the c- Returns:
- the object
- See Also:
EmgRandomGenerator.nextFromCollection(java.util.Collection)
-
nextFromList
public Object nextFromList(String listID) throws EolRuntimeException
The listID is the value of a @list annotation of a create operation. If no create operation with that @list annotation value is found, the operation is delegated to the underlyingEmgRandomGenerator
.- Specified by:
nextFromList
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
listID
- the list ID- Returns:
- the object
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextFromList(java.lang.String)
-
nextFromListAsSample
public Object nextFromListAsSample(String listID) throws EolRuntimeException
The listID is the value of a @list annotation of a create operation. If no create operation with that @list annotation value is found, the operation is delegated to the underlyingEmgRandomGenerator
.- Specified by:
nextFromListAsSample
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
listID
- the list ID- Returns:
- the object
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
org.eclipse.epsilon.emg.random.EmgRandomGenerator#nextSampleFromList(java.lang.String)
-
nextGaussian
public double nextGaussian()
- Specified by:
nextGaussian
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextGaussian()
-
nextHttpURI
public String nextHttpURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment) throws EolRuntimeException
Next http URI.- Specified by:
nextHttpURI
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
addPort
- the add portaddPath
- the add pathaddQuery
- the add queryaddFragment
- the add fragment- Returns:
- the string
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextHttpURI(boolean, boolean, boolean, boolean)
-
nextInt
public int nextInt()
- Specified by:
nextInt
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextInt()
-
nextInt
public int nextInt(int n)
- Specified by:
nextInt
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Parameters:
n
-- Returns:
- See Also:
EmgRandomGenerator.nextInt(int)
-
nextInteger
public int nextInteger(int upper) throws EolRuntimeException
Next integer.- Specified by:
nextInteger
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
upper
- the upper- Returns:
- the int
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextInteger(int)
-
nextInteger
public int nextInteger(int lower, int upper) throws EolRuntimeException
Next integer.- Specified by:
nextInteger
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
lower
- the lowerupper
- the upper- Returns:
- the int
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextInteger(int, int)
-
nextLong
public long nextLong()
- Specified by:
nextLong
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Returns:
- See Also:
EmgRandomGenerator.nextLong()
-
nextLong
public long nextLong(long upper) throws EolRuntimeException
Next long.- Specified by:
nextLong
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
upper
- the upper- Returns:
- the long
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextLong(long)
-
nextLong
public long nextLong(long lower, long upper) throws EolRuntimeException
Next long.- Specified by:
nextLong
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
lower
- the lowerupper
- the upper- Returns:
- the long
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextLong(long, long)
-
nextSample
public List<Object> nextSample(Collection<?> c, int k) throws EolRuntimeException
Next sample.- Specified by:
nextSample
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
c
- the ck
- the k- Returns:
- the list
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextSample(java.util.Collection, int)
-
nextSample
public List<Object> nextSample(String listID, int k) throws EolRuntimeException
The listID is the value of a @list annotation of a create operation. If no create operation with that @list annotation value is found, the operation is delegated to the underlyingEmgRandomGenerator
.- Specified by:
nextSample
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
listID
- the list IDk
- the k- Returns:
- the list
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextSample(java.lang.String, int)
-
nextString
public String nextString(String charSet, int length)
Next string.- Specified by:
nextString
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
charSet
- the char setlength
- the length- Returns:
- the string
- See Also:
EmgRandomGenerator.nextString(java.lang.String, int)
-
nextURI
public String nextURI() throws EolRuntimeException
Next URI.- Specified by:
nextURI
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Returns:
- the string
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextURI()
-
nextURI
public String nextURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment) throws EolRuntimeException
Next URI.- Specified by:
nextURI
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Parameters:
addPort
- the add portaddPath
- the add pathaddQuery
- the add queryaddFragment
- the add fragment- Returns:
- the string
- Throws:
EolRuntimeException
- the eol runtime exception- See Also:
EmgRandomGenerator.nextURI(boolean, boolean, boolean, boolean)
-
nextValue
public double nextValue()
Next value.- Specified by:
nextValue
in interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>
- Returns:
- the double
- See Also:
EmgRandomGenerator.nextValue()
-
setHasids_salt
public void setHasids_salt(String hasids_salt)
Sets the hasids salt.- Parameters:
hasids_salt
- the hasids_salt to set
-
setSeed
public void setSeed(int seed)
- Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Parameters:
seed
-- See Also:
EmgRandomGenerator.setSeed(int)
-
setSeed
public void setSeed(int[] seed)
- Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Parameters:
seed
-- See Also:
EmgRandomGenerator.setSeed(int[])
-
setSeed
public void setSeed(long seed)
- Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
- Parameters:
seed
-- See Also:
EmgRandomGenerator.setSeed(long)
-
useBinomialDistribution
public void useBinomialDistribution(int numberOfTrials, double probabilityOfSuccess)
Use binomial distribution.- Parameters:
numberOfTrials
- the number of trialsprobabilityOfSuccess
- the probability of success- See Also:
EmgRandomGenerator.useBinomialDistribution(int, double)
-
useExponentialDistribution
public void useExponentialDistribution(double mean)
Use exponential distribution.- Parameters:
mean
- the mean- See Also:
EmgRandomGenerator.useExponentialDistribution(double)
-
-