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 booleancontributesTo(Object target)long[]decode(String hash)Decode string to numbers.Stringencode(int number)Encrypt numbers to string.StringgetHasids_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.doublenextBinomialValue(int numberOfTrials, double probabilityOfSuccess)Next binomial value.booleannextBoolean()voidnextBytes(byte[] bytes)StringnextCamelCaseString(int length, int minWordLength)Next camel case string.StringnextCapitalisedString(String charSet, int length)Next capitalised string.doublenextDobule(double upper)Next dobule.doublenextDobule(double lower, double upper)Next dobule.doublenextDouble()doublenextExponentialValue(double mean)Next exponential value.floatnextFloat()ObjectnextFromCollection(Collection<?> c)Next from collection.ObjectnextFromList(String listID)The listID is the value of a @list annotation of a create operation.ObjectnextFromListAsSample(String listID)The listID is the value of a @list annotation of a create operation.doublenextGaussian()StringnextHttpURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)Next http URI.intnextInt()intnextInt(int n)intnextInteger(int upper)Next integer.intnextInteger(int lower, int upper)Next integer.longnextLong()longnextLong(long upper)Next long.longnextLong(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.StringnextString(String charSet, int length)Next string.StringnextURI()Next URI.StringnextURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)Next URI.doublenextValue()Next value.voidsetHasids_salt(String hasids_salt)Sets the hasids salt.voidsetSeed(int seed)voidsetSeed(int[] seed)voidsetSeed(long seed)voiduseBinomialDistribution(int numberOfTrials, double probabilityOfSuccess)Use binomial distribution.voiduseExponentialDistribution(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:
contributesToin 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:IEmgRandomGeneratorReturns an array of n integers that addvar to m.- Specified by:
nextAddToin interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>- Returns:
- Throws:
EolRuntimeException
-
nextBinomialValue
public double nextBinomialValue(int numberOfTrials, double probabilityOfSuccess)Next binomial value.- Specified by:
nextBinomialValuein 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:
nextBooleanin interfaceorg.apache.commons.math3.random.RandomGenerator- Returns:
- See Also:
EmgRandomGenerator.nextBoolean()
-
nextBytes
public void nextBytes(byte[] bytes)
- Specified by:
nextBytesin 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:
nextCamelCaseStringin 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:
nextCapitalisedStringin 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 EolRuntimeExceptionNext dobule.- Specified by:
nextDobulein 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:
nextDobulein interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>- Parameters:
lower- the lowerupper- the upper- Returns:
- the double
- See Also:
EmgRandomGenerator.nextDobule(double, double)
-
nextDouble
public double nextDouble()
- Specified by:
nextDoublein interfaceorg.apache.commons.math3.random.RandomGenerator- Returns:
- See Also:
EmgRandomGenerator.nextDouble()
-
nextExponentialValue
public double nextExponentialValue(double mean)
Next exponential value.- Specified by:
nextExponentialValuein interfaceIEmgRandomGenerator<IEmgRandomGenerator.DefaultCharacterSet>- Parameters:
mean- the mean- Returns:
- the double
- See Also:
EmgRandomGenerator.nextExponentialValue(double)
-
nextFloat
public float nextFloat()
- Specified by:
nextFloatin interfaceorg.apache.commons.math3.random.RandomGenerator- Returns:
- See Also:
EmgRandomGenerator.nextFloat()
-
nextFromCollection
public Object nextFromCollection(Collection<?> c)
Next from collection.- Specified by:
nextFromCollectionin 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:
nextFromListin 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:
nextFromListAsSamplein 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:
nextGaussianin 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:
nextHttpURIin 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:
nextIntin interfaceorg.apache.commons.math3.random.RandomGenerator- Returns:
- See Also:
EmgRandomGenerator.nextInt()
-
nextInt
public int nextInt(int n)
- Specified by:
nextIntin interfaceorg.apache.commons.math3.random.RandomGenerator- Parameters:
n-- Returns:
- See Also:
EmgRandomGenerator.nextInt(int)
-
nextInteger
public int nextInteger(int upper) throws EolRuntimeExceptionNext integer.- Specified by:
nextIntegerin 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 EolRuntimeExceptionNext integer.- Specified by:
nextIntegerin 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:
nextLongin interfaceorg.apache.commons.math3.random.RandomGenerator- Returns:
- See Also:
EmgRandomGenerator.nextLong()
-
nextLong
public long nextLong(long upper) throws EolRuntimeExceptionNext long.- Specified by:
nextLongin 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 EolRuntimeExceptionNext long.- Specified by:
nextLongin 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:
nextSamplein 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:
nextSamplein 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:
nextStringin 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:
nextURIin 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:
nextURIin 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:
nextValuein 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:
setSeedin interfaceorg.apache.commons.math3.random.RandomGenerator- Parameters:
seed-- See Also:
EmgRandomGenerator.setSeed(int)
-
setSeed
public void setSeed(int[] seed)
- Specified by:
setSeedin interfaceorg.apache.commons.math3.random.RandomGenerator- Parameters:
seed-- See Also:
EmgRandomGenerator.setSeed(int[])
-
setSeed
public void setSeed(long seed)
- Specified by:
setSeedin 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)
-
-