[New] Added new convenience methods for getting and setting parameters
This commit is contained in:
parent
1398bdd0e7
commit
8f645d1af7
|
@ -20,15 +20,16 @@ import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
|
|||
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import li.strolch.exception.StrolchException;
|
||||
import li.strolch.exception.StrolchModelException;
|
||||
import li.strolch.model.parameter.Parameter;
|
||||
import li.strolch.model.parameter.StringListParameter;
|
||||
import li.strolch.model.parameter.StringParameter;
|
||||
import li.strolch.model.parameter.*;
|
||||
import li.strolch.utils.helper.StringHelper;
|
||||
import li.strolch.utils.time.PeriodDuration;
|
||||
|
||||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
|
@ -82,6 +83,462 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getString(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getString(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getBoolean(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getBoolean(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getInteger(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getInteger(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDouble(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDouble(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getLong(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getLong(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZonedDateTime getDate(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDate(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZonedDateTime getDate(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDate(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getLocalDate(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getLocalDate(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getLocalDate(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getLocalDate(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getText(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getText(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PeriodDuration getDuration(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDuration(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PeriodDuration getDuration(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDuration(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getStringList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getStringList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getIntegerList(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getIntegerList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getIntegerList(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getIntegerList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Double> getDoubleList(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDoubleList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Double> getDoubleList(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDoubleList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getLongList(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getLongList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getLongList(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getLongList(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(String paramKey, String value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setString(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(String bagKey, String paramKey, String value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setString(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(String paramKey, boolean value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setBoolean(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(String bagKey, String paramKey, boolean value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setBoolean(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteger(String paramKey, int value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setInteger(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteger(String bagKey, String paramKey, int value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setInteger(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(String paramKey, double value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setDouble(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(String bagKey, String paramKey, double value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setDouble(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(String paramKey, long value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setLong(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(String bagKey, String paramKey, long value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setLong(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(String paramKey, ZonedDateTime value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setDate(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(String bagKey, String paramKey, ZonedDateTime value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setDate(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(String paramKey, LocalDateTime value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setDate(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(String bagKey, String paramKey, LocalDateTime value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setDate(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String paramKey, String value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setText(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String bagKey, String paramKey, String value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setText(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(String paramKey, PeriodDuration value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setDuration(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(String bagKey, String paramKey, PeriodDuration value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setDuration(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringList(String paramKey, List<String> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setStringList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringList(String bagKey, String paramKey, List<String> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setStringList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegerList(String paramKey, List<Integer> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setIntegerList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegerList(String bagKey, String paramKey, List<Integer> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setIntegerList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoubleList(String paramKey, List<Double> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setDoubleList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoubleList(String bagKey, String paramKey, List<Double> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setDoubleList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLongList(String paramKey, List<Long> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
bag.setLongList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLongList(String bagKey, String paramKey, List<Long> value) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
bag.setLongList(paramKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParameter getStringP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getStringP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParameter getStringP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getStringP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanParameter getBooleanP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getBooleanP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanParameter getBooleanP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getBooleanP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegerParameter getIntegerP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getIntegerP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegerParameter getIntegerP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getIntegerP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatParameter getDoubleP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDoubleP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatParameter getDoubleP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDoubleP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongParameter getLongP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getLongP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongParameter getLongP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getLongP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateParameter getDateP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDateP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateParameter getDateP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDateP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextParameter getTextP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getTextP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextParameter getTextP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getTextP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DurationParameter getDurationP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDurationP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DurationParameter getDurationP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDurationP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringListParameter getStringListP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getStringListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringListParameter getStringListP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getStringListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegerListParameter getIntegerListP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getIntegerListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegerListParameter getIntegerListP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getIntegerListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatListParameter getDoubleListP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getDoubleListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatListParameter getDoubleListP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getDoubleListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongListParameter getLongListP(String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(BAG_PARAMETERS, true);
|
||||
return bag.getLongListP(paramKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongListParameter getLongListP(String bagKey, String paramKey) throws StrolchModelException {
|
||||
ParameterBag bag = getParameterBag(bagKey, true);
|
||||
return bag.getLongListP(paramKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if
|
||||
* the {@link Parameter} or the {@link ParameterBag} does not exist
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,6 +19,8 @@ import static java.util.stream.Collectors.toList;
|
|||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -26,8 +28,9 @@ import java.util.stream.Stream;
|
|||
import li.strolch.exception.StrolchException;
|
||||
import li.strolch.exception.StrolchModelException;
|
||||
import li.strolch.model.Locator.LocatorBuilder;
|
||||
import li.strolch.model.parameter.Parameter;
|
||||
import li.strolch.model.parameter.*;
|
||||
import li.strolch.utils.helper.StringHelper;
|
||||
import li.strolch.utils.time.PeriodDuration;
|
||||
|
||||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
|
@ -83,6 +86,605 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link StringParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public String getString(String paramKey) throws StrolchModelException {
|
||||
StringParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link BooleanParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public boolean getBoolean(String paramKey) throws StrolchModelException {
|
||||
BooleanParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link IntegerParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public int getInteger(String paramKey) throws StrolchModelException {
|
||||
IntegerParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link FloatParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public double getDouble(String paramKey) throws StrolchModelException {
|
||||
FloatParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link LongParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public long getLong(String paramKey) throws StrolchModelException {
|
||||
LongParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link DateParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public ZonedDateTime getDate(String paramKey) throws StrolchModelException {
|
||||
DateParameter param = getParameter(paramKey, true);
|
||||
return param.toZonedDateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link DateParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public LocalDateTime getLocalDate(String paramKey) throws StrolchModelException {
|
||||
DateParameter param = getParameter(paramKey, true);
|
||||
return param.toLocalDateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link TextParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public String getText(String paramKey) throws StrolchModelException {
|
||||
TextParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link DurationParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public PeriodDuration getDuration(String paramKey) throws StrolchModelException {
|
||||
DurationParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link StringListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public List<String> getStringList(String paramKey) throws StrolchModelException {
|
||||
StringListParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link IntegerListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public List<Integer> getIntegerList(String paramKey) throws StrolchModelException {
|
||||
IntegerListParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link FloatListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public List<Double> getDoubleList(String paramKey) throws StrolchModelException {
|
||||
FloatListParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the {@link LongListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
*
|
||||
* @return the value of the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public List<Long> getLongList(String paramKey) throws StrolchModelException {
|
||||
LongListParameter param = getParameter(paramKey, true);
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link StringParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setString(String paramKey, String value) throws StrolchModelException {
|
||||
StringParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link BooleanParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setBoolean(String paramKey, boolean value) throws StrolchModelException {
|
||||
BooleanParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link IntegerParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setInteger(String paramKey, int value) throws StrolchModelException {
|
||||
IntegerParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link FloatParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setDouble(String paramKey, double value) throws StrolchModelException {
|
||||
FloatParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link LongParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setLong(String paramKey, long value) throws StrolchModelException {
|
||||
LongParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link DateParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setDate(String paramKey, ZonedDateTime value) throws StrolchModelException {
|
||||
DateParameter param = getParameter(paramKey, true);
|
||||
param.setValueFromZonedDateTime(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link DateParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setDate(String paramKey, LocalDateTime value) throws StrolchModelException {
|
||||
DateParameter param = getParameter(paramKey, true);
|
||||
param.setValueFromLocalDateTime(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link TextParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setText(String paramKey, String value) throws StrolchModelException {
|
||||
TextParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link DurationParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setDuration(String paramKey, PeriodDuration value) throws StrolchModelException {
|
||||
DurationParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link StringListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setStringList(String paramKey, List<String> value) throws StrolchModelException {
|
||||
StringListParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link IntegerListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setIntegerList(String paramKey, List<Integer> value) throws StrolchModelException {
|
||||
IntegerListParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link FloatListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setDoubleList(String paramKey, List<Double> value) throws StrolchModelException {
|
||||
FloatListParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value on the {@link LongListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter for which to return the value
|
||||
* @param value
|
||||
* the value to set on the parameter
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public void setLongList(String paramKey, List<Long> value) throws StrolchModelException {
|
||||
LongListParameter param = getParameter(paramKey, true);
|
||||
param.setValue(value);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
|
||||
/**
|
||||
* Returns the {@link StringParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public StringParameter getStringP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link BooleanParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public BooleanParameter getBooleanP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link IntegerParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public IntegerParameter getIntegerP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link FloatParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public FloatParameter getDoubleP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link LongParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public LongParameter getLongP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link DateParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public DateParameter getDateP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link TextParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public TextParameter getTextP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link DurationParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public DurationParameter getDurationP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link StringListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public StringListParameter getStringListP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link IntegerListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public IntegerListParameter getIntegerListP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link FloatListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public FloatListParameter getDoubleListP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link LongListParameter} with the given paramKey
|
||||
*
|
||||
* @param paramKey
|
||||
* the key of the parameter
|
||||
*
|
||||
* @return the parameter with the given paramKey
|
||||
*
|
||||
* @throws StrolchModelException
|
||||
* if the parameter does not exist
|
||||
*/
|
||||
public LongListParameter getLongListP(String paramKey) throws StrolchModelException {
|
||||
return getParameter(paramKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Parameter} with the given id, or null if it does not exist
|
||||
*
|
||||
|
|
|
@ -18,9 +18,12 @@ package li.strolch.model;
|
|||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static li.strolch.model.ModelGenerator.*;
|
||||
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
|
||||
import static li.strolch.model.Tags.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -36,6 +39,7 @@ import li.strolch.model.timevalue.impl.BooleanValue;
|
|||
import li.strolch.model.timevalue.impl.IntegerValue;
|
||||
import li.strolch.model.timevalue.impl.ValueChange;
|
||||
import li.strolch.model.visitor.StrolchElementDeepEqualsVisitor;
|
||||
import li.strolch.utils.time.PeriodDuration;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -516,4 +520,211 @@ public class ModelTest {
|
|||
assertEquals(STATE_STRING_TIME_20, stringState.getStateAt(STATE_TIME_20).getValue().getValueAsString());
|
||||
assertEquals(STATE_STRING_TIME_30, stringState.getStateAt(STATE_TIME_30).getValue().getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetSetValues() {
|
||||
|
||||
Resource resource = createResource("@res01", "Test resource", "MyType");
|
||||
resource.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertGetSetParameterValues(resource);
|
||||
|
||||
Order order = createOrder("@ord01", "Test Order", "MyType");
|
||||
order.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertGetSetParameterValues(order);
|
||||
|
||||
Activity activity = createActivity("@act01", "Test Activity", "MyType", TimeOrdering.SERIES);
|
||||
activity.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertGetSetParameterValues(activity);
|
||||
|
||||
Action action = createAction("action", "Action", "Use");
|
||||
action.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertGetSetParameterValues(action);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetParams() {
|
||||
|
||||
Resource resource = createResource("@res01", "Test resource", "MyType");
|
||||
resource.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertParameters(resource);
|
||||
|
||||
Order order = createOrder("@ord01", "Test Order", "MyType");
|
||||
order.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertParameters(order);
|
||||
|
||||
Activity activity = createActivity("@act01", "Test Activity", "MyType", TimeOrdering.SERIES);
|
||||
activity.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertParameters(activity);
|
||||
|
||||
Action action = createAction("action", "Action", "Use");
|
||||
action.addParameterBag(createParameterBag(BAG_PARAMETERS, "Parameters", "Parameters"));
|
||||
assertParameters(action);
|
||||
}
|
||||
|
||||
private void assertParameters(GroupedParameterizedElement e) {
|
||||
|
||||
// default "parameters" bag
|
||||
assertEquals(StrolchValueType.BOOLEAN, e.getBooleanP(PARAM_BOOLEAN_ID).getValueType());
|
||||
assertEquals(StrolchValueType.INTEGER, e.getIntegerP(PARAM_INTEGER_ID).getValueType());
|
||||
assertEquals(StrolchValueType.FLOAT, e.getDoubleP(PARAM_FLOAT_ID).getValueType());
|
||||
assertEquals(StrolchValueType.STRING, e.getStringP(PARAM_STRING_ID).getValueType());
|
||||
assertEquals(StrolchValueType.LONG, e.getLongP(PARAM_LONG_ID).getValueType());
|
||||
assertEquals(StrolchValueType.TEXT, e.getTextP(PARAM_TEXT_ID).getValueType());
|
||||
assertEquals(StrolchValueType.DATE, e.getDateP(PARAM_DATE_ID).getValueType());
|
||||
assertEquals(StrolchValueType.DURATION, e.getDurationP(PARAM_DURATION_ID).getValueType());
|
||||
assertEquals(StrolchValueType.STRING_LIST, e.getStringListP(PARAM_LIST_STRING_ID).getValueType());
|
||||
assertEquals(StrolchValueType.INTEGER_LIST, e.getIntegerListP(PARAM_LIST_INTEGER_ID).getValueType());
|
||||
assertEquals(StrolchValueType.LONG_LIST, e.getLongListP(PARAM_LIST_LONG_ID).getValueType());
|
||||
assertEquals(StrolchValueType.FLOAT_LIST, e.getDoubleListP(PARAM_LIST_FLOAT_ID).getValueType());
|
||||
|
||||
// explicit bag
|
||||
assertEquals(StrolchValueType.BOOLEAN, e.getBooleanP(BAG_ID, PARAM_BOOLEAN_ID).getValueType());
|
||||
assertEquals(StrolchValueType.INTEGER, e.getIntegerP(BAG_ID, PARAM_INTEGER_ID).getValueType());
|
||||
assertEquals(StrolchValueType.FLOAT, e.getDoubleP(BAG_ID, PARAM_FLOAT_ID).getValueType());
|
||||
assertEquals(StrolchValueType.STRING, e.getStringP(BAG_ID, PARAM_STRING_ID).getValueType());
|
||||
assertEquals(StrolchValueType.LONG, e.getLongP(BAG_ID, PARAM_LONG_ID).getValueType());
|
||||
assertEquals(StrolchValueType.TEXT, e.getTextP(BAG_ID, PARAM_TEXT_ID).getValueType());
|
||||
assertEquals(StrolchValueType.DATE, e.getDateP(BAG_ID, PARAM_DATE_ID).getValueType());
|
||||
assertEquals(StrolchValueType.DURATION, e.getDurationP(BAG_ID, PARAM_DURATION_ID).getValueType());
|
||||
assertEquals(StrolchValueType.STRING_LIST, e.getStringListP(BAG_ID, PARAM_LIST_STRING_ID).getValueType());
|
||||
assertEquals(StrolchValueType.INTEGER_LIST, e.getIntegerListP(BAG_ID, PARAM_LIST_INTEGER_ID).getValueType());
|
||||
assertEquals(StrolchValueType.LONG_LIST, e.getLongListP(BAG_ID, PARAM_LIST_LONG_ID).getValueType());
|
||||
assertEquals(StrolchValueType.FLOAT_LIST, e.getDoubleListP(BAG_ID, PARAM_LIST_FLOAT_ID).getValueType());
|
||||
}
|
||||
|
||||
private void assertGetSetParameterValues(GroupedParameterizedElement e) {
|
||||
|
||||
/*
|
||||
* default "parameters" bag
|
||||
*/
|
||||
|
||||
// boolean param
|
||||
assertTrue(e.getBoolean(PARAM_BOOLEAN_ID));
|
||||
e.setBoolean(PARAM_BOOLEAN_ID, false);
|
||||
assertFalse(e.getBoolean(PARAM_BOOLEAN_ID));
|
||||
|
||||
// integer param
|
||||
assertEquals(77, e.getInteger(PARAM_INTEGER_ID));
|
||||
e.setInteger(PARAM_INTEGER_ID, 88);
|
||||
assertEquals(88, e.getInteger(PARAM_INTEGER_ID));
|
||||
|
||||
// float param
|
||||
assertEquals(44.3, e.getDouble(PARAM_FLOAT_ID), 0.0);
|
||||
e.setDouble(PARAM_FLOAT_ID, 56.0);
|
||||
assertEquals(56.0, e.getDouble(PARAM_FLOAT_ID), 0.0);
|
||||
|
||||
// string param
|
||||
assertEquals("Strolch", e.getString(PARAM_STRING_ID));
|
||||
e.setString(PARAM_STRING_ID, "aa");
|
||||
assertEquals("aa", e.getString(PARAM_STRING_ID));
|
||||
|
||||
// long param
|
||||
assertEquals(4453234566L, e.getLong(PARAM_LONG_ID));
|
||||
e.setLong(PARAM_LONG_ID, 0L);
|
||||
assertEquals(0L, e.getLong(PARAM_LONG_ID));
|
||||
|
||||
// text param
|
||||
assertEquals("Strolch\n\nmulti\n\n\nline", e.getText(PARAM_TEXT_ID));
|
||||
e.setText(PARAM_TEXT_ID, "bla");
|
||||
assertEquals("bla", e.getText(PARAM_TEXT_ID));
|
||||
|
||||
// date param
|
||||
assertEquals(ZonedDateTime.ofInstant(new Date(1354295525628L).toInstant(), ZoneId.systemDefault()),
|
||||
e.getDate(PARAM_DATE_ID));
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
e.setDate(PARAM_DATE_ID, now);
|
||||
assertEquals(now, e.getDate(PARAM_DATE_ID));
|
||||
|
||||
// duration param
|
||||
assertEquals(PeriodDuration.parse("P1D"), e.getDuration(PARAM_DURATION_ID));
|
||||
e.setDuration(PARAM_DURATION_ID, PeriodDuration.parse("PT1H"));
|
||||
assertEquals(PeriodDuration.parse("PT1H"), e.getDuration(PARAM_DURATION_ID));
|
||||
|
||||
// string list param
|
||||
assertEquals(asList("Hello", "World"), e.getStringList(PARAM_LIST_STRING_ID));
|
||||
e.setStringList(PARAM_LIST_STRING_ID, asList("a", "b"));
|
||||
assertEquals(asList("a", "b"), e.getStringList(PARAM_LIST_STRING_ID));
|
||||
|
||||
// integer list param
|
||||
assertEquals(asList(5, 10, 15), e.getIntegerList(PARAM_LIST_INTEGER_ID));
|
||||
e.setIntegerList(PARAM_LIST_INTEGER_ID, asList(6, 2));
|
||||
assertEquals(asList(6, 2), e.getIntegerList(PARAM_LIST_INTEGER_ID));
|
||||
|
||||
// long list param
|
||||
assertEquals(asList(7L, 12L, 17L), e.getLongList(PARAM_LIST_LONG_ID));
|
||||
e.setLongList(PARAM_LIST_LONG_ID, asList(6L, 2L));
|
||||
assertEquals(asList(6L, 2L), e.getLongList(PARAM_LIST_LONG_ID));
|
||||
|
||||
// float list param
|
||||
assertEquals(asList(6.0, 11.0, 16.0), e.getDoubleList(PARAM_LIST_FLOAT_ID));
|
||||
e.setDoubleList(PARAM_LIST_FLOAT_ID, asList(6.0, 2.0));
|
||||
assertEquals(asList(6.0, 2.0), e.getDoubleList(PARAM_LIST_FLOAT_ID));
|
||||
|
||||
|
||||
/*
|
||||
* explicit bag
|
||||
*/
|
||||
|
||||
// boolean param
|
||||
assertTrue(e.getBoolean(BAG_ID, PARAM_BOOLEAN_ID));
|
||||
e.setBoolean(BAG_ID, PARAM_BOOLEAN_ID, false);
|
||||
assertFalse(e.getBoolean(BAG_ID, PARAM_BOOLEAN_ID));
|
||||
|
||||
// integer param
|
||||
assertEquals(77, e.getInteger(BAG_ID, PARAM_INTEGER_ID));
|
||||
e.setInteger(BAG_ID, PARAM_INTEGER_ID, 188);
|
||||
assertEquals(188, e.getInteger(BAG_ID, PARAM_INTEGER_ID));
|
||||
|
||||
// float param
|
||||
assertEquals(44.3, e.getDouble(BAG_ID, PARAM_FLOAT_ID), 0.0);
|
||||
e.setDouble(BAG_ID, PARAM_FLOAT_ID, 156.0);
|
||||
assertEquals(156.0, e.getDouble(BAG_ID, PARAM_FLOAT_ID), 0.0);
|
||||
|
||||
// string param
|
||||
assertEquals("Strolch", e.getString(BAG_ID, PARAM_STRING_ID));
|
||||
e.setString(BAG_ID, PARAM_STRING_ID, "aaa");
|
||||
assertEquals("aaa", e.getString(BAG_ID, PARAM_STRING_ID));
|
||||
|
||||
// long param
|
||||
assertEquals(4453234566L, e.getLong(BAG_ID, PARAM_LONG_ID));
|
||||
e.setLong(BAG_ID, PARAM_LONG_ID, 1L);
|
||||
assertEquals(1L, e.getLong(BAG_ID, PARAM_LONG_ID));
|
||||
|
||||
// text param
|
||||
assertEquals("Strolch\n\nmulti\n\n\nline", e.getText(BAG_ID, PARAM_TEXT_ID));
|
||||
e.setText(BAG_ID, PARAM_TEXT_ID, "bla bla");
|
||||
assertEquals("bla bla", e.getText(BAG_ID, PARAM_TEXT_ID));
|
||||
|
||||
// date param
|
||||
assertEquals(ZonedDateTime.ofInstant(new Date(1354295525628L).toInstant(), ZoneId.systemDefault()),
|
||||
e.getDate(BAG_ID, PARAM_DATE_ID));
|
||||
now = ZonedDateTime.now().plusDays(1);
|
||||
e.setDate(BAG_ID, PARAM_DATE_ID, now);
|
||||
assertEquals(now, e.getDate(BAG_ID, PARAM_DATE_ID));
|
||||
|
||||
// duration param
|
||||
assertEquals(PeriodDuration.parse("P1D"), e.getDuration(BAG_ID, PARAM_DURATION_ID));
|
||||
e.setDuration(BAG_ID, PARAM_DURATION_ID, PeriodDuration.parse("PT2H"));
|
||||
assertEquals(PeriodDuration.parse("PT2H"), e.getDuration(BAG_ID, PARAM_DURATION_ID));
|
||||
|
||||
// string list param
|
||||
assertEquals(asList("Hello", "World"), e.getStringList(BAG_ID, PARAM_LIST_STRING_ID));
|
||||
e.setStringList(BAG_ID, PARAM_LIST_STRING_ID, asList("aa", "b"));
|
||||
assertEquals(asList("aa", "b"), e.getStringList(BAG_ID, PARAM_LIST_STRING_ID));
|
||||
|
||||
// integer list param
|
||||
assertEquals(asList(5, 10, 15), e.getIntegerList(BAG_ID, PARAM_LIST_INTEGER_ID));
|
||||
e.setIntegerList(BAG_ID, PARAM_LIST_INTEGER_ID, asList(76, 2));
|
||||
assertEquals(asList(76, 2), e.getIntegerList(BAG_ID, PARAM_LIST_INTEGER_ID));
|
||||
|
||||
// long list param
|
||||
assertEquals(asList(7L, 12L, 17L), e.getLongList(BAG_ID, PARAM_LIST_LONG_ID));
|
||||
e.setLongList(BAG_ID, PARAM_LIST_LONG_ID, asList(76L, 2L));
|
||||
assertEquals(asList(76L, 2L), e.getLongList(BAG_ID, PARAM_LIST_LONG_ID));
|
||||
|
||||
// float list param
|
||||
assertEquals(asList(6.0, 11.0, 16.0), e.getDoubleList(BAG_ID, PARAM_LIST_FLOAT_ID));
|
||||
e.setDoubleList(BAG_ID, PARAM_LIST_FLOAT_ID, asList(76.0, 2.0));
|
||||
assertEquals(asList(76.0, 2.0), e.getDoubleList(BAG_ID, PARAM_LIST_FLOAT_ID));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue