Class IndexBasedModelConverter
- java.lang.Object
-
- de.rwth.swc.coffee4j.engine.converter.model.IndexBasedModelConverter
-
- All Implemented Interfaces:
ModelConverter
public class IndexBasedModelConverter extends Object implements ModelConverter
AModelConverter
based on using the indices of suppliedParameter
andValue
. This means that the first parameter in the list ofInputParameterModel.getParameters()
is translated to 0, the second one to 1 and so on and so fourth. The same is done with values per parameter. These integers are then used forTupleList
andCombination
, so [0, 1] is a combination where the first parameter is mapped to it's first value and the second one to its second value.
-
-
Constructor Summary
Constructors Constructor Description IndexBasedModelConverter(InputParameterModel model)
Creates and initializes a new converter with the given testModel and constraints converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Combination
convertCombination(int[] combination)
Converts a combinations represented by an integer array into aCombination
object with the corresponding parameters and values.int[]
convertCombination(Combination combination)
Converts aCombination
object to an integer array representation with the corresponding value number.Constraint
convertConstraint(TupleList constraint)
Converts aTupleList
object into aConstraint
representation which is equal.TupleList
convertConstraint(Constraint constraint)
Converts aConstraint
object into aTupleList
representation which is equal.Parameter
convertParameter(int parameter)
Converts an integer representation back to aParameter
object.int
convertParameter(Parameter parameter)
Converts aParameter
object into an equivalent integer representation.Value
convertValue(int parameter, int value)
Converts the integer representation of a value into aValue
object.int
convertValue(Parameter parameter, Value value)
Converts aValue
to an integer representation.CompleteTestModel
getConvertedModel()
InputParameterModel
getModel()
-
-
-
Constructor Detail
-
IndexBasedModelConverter
public IndexBasedModelConverter(InputParameterModel model)
Creates and initializes a new converter with the given testModel and constraints converter.- Parameters:
model
- the testModel which is converted. Must not benull
-
-
Method Detail
-
getModel
public InputParameterModel getModel()
- Specified by:
getModel
in interfaceModelConverter
- Returns:
- the original testModel which is converted by this
ModelConverter
-
getConvertedModel
public CompleteTestModel getConvertedModel()
- Specified by:
getConvertedModel
in interfaceModelConverter
- Returns:
- the conversion of the original testModel (
ModelConverter.getModel()
)
-
convertCombination
public int[] convertCombination(Combination combination)
Description copied from interface:ModelConverter
Converts aCombination
object to an integer array representation with the corresponding value number. If the array returned by this method is given intoModelConverter.convertCombination(int[])
, aCombination
equal to the original one should be returned.- Specified by:
convertCombination
in interfaceModelConverter
- Parameters:
combination
- the combination to be converted. Must not benull
- Returns:
- the corresponding integer array to that it matches the testModel conversion
-
convertCombination
public Combination convertCombination(int[] combination)
Description copied from interface:ModelConverter
Converts a combinations represented by an integer array into aCombination
object with the corresponding parameters and values.- Specified by:
convertCombination
in interfaceModelConverter
- Parameters:
combination
- the combination to be converted. Must not benull
- Returns:
- the corresponding
Combination
so that it matches the testModel conversion
-
convertParameter
public int convertParameter(Parameter parameter)
Description copied from interface:ModelConverter
Converts aParameter
object into an equivalent integer representation. If the integer returned by this method is given toModelConverter.convertParameter(int)
, the original parameter is returned.- Specified by:
convertParameter
in interfaceModelConverter
- Parameters:
parameter
- the parameter to convert. Needs to be in the original testModel, otherwise success of this method is not guaranteed. Must not benull
- Returns:
- the corresponding integer representation so that it matches the testModel conversion
-
convertParameter
public Parameter convertParameter(int parameter)
Description copied from interface:ModelConverter
Converts an integer representation back to aParameter
object.- Specified by:
convertParameter
in interfaceModelConverter
- Parameters:
parameter
- the parameter to convert. Needs to be in the original testModel, otherwise success of this method is not guaranteed. Must not be negative- Returns:
- the corresponding
Parameter
representation so that it matches the testModel conversion
-
convertValue
public int convertValue(Parameter parameter, Value value)
Description copied from interface:ModelConverter
Converts aValue
to an integer representation. As values are only unique in their correspondingParameter
s, the parameter is needed as well. It can be converted usingModelConverter.convertParameter(Parameter)
. If the converted value and parameter are given toModelConverter.convertValue(int, int)
, the original value is returned.- Specified by:
convertValue
in interfaceModelConverter
- Parameters:
parameter
- the parameter in which the value is locatedvalue
- the value to convert- Returns:
- the corresponding integer representation so that it matches the testModel conversion
-
convertValue
public Value convertValue(int parameter, int value)
Description copied from interface:ModelConverter
Converts the integer representation of a value into aValue
object. The parameter is needed since values are only unique in the context of their parameters. The parameter can be converted withModelConverter.convertParameter(int)
.- Specified by:
convertValue
in interfaceModelConverter
- Parameters:
parameter
- the parameter in which the value is locatedvalue
- the value to convert- Returns:
- the corresponding
Value
representation so that it matches the testModel conversion
-
convertConstraint
public TupleList convertConstraint(Constraint constraint)
Description copied from interface:ModelConverter
Converts aConstraint
object into aTupleList
representation which is equal. If theTupleList
returned by this method is given toModelConverter.convertConstraint(TupleList)
, the original constraint will be returned.- Specified by:
convertConstraint
in interfaceModelConverter
- Parameters:
constraint
- the constraint to convert. Needs to be one in the original testModel, otherwise success of this method is not guaranteed. Must not benull
- Returns:
- the corresponding
TupleList
representation so that it matches the testModel conversion
-
convertConstraint
public Constraint convertConstraint(TupleList constraint)
Description copied from interface:ModelConverter
Converts aTupleList
object into aConstraint
representation which is equal.- Specified by:
convertConstraint
in interfaceModelConverter
- Parameters:
constraint
- the constraint to convert. Needs to be one in the original testModel, otherwise success of this method is not guaranteed. Must not benull
- Returns:
- the corresponding
MethodBasedConstraint
representation so that it matches the testModel conversion
-
-