diff --git a/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java b/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java index 9f928c451..16a8d7746 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java +++ b/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java @@ -82,6 +82,9 @@ public class ModelGenerator { public static final String STATE_FLOAT_LIST_ID = "@state5"; public static final String STATE_FLOAT_LIST_NAME = "Float List State"; + public static final String STATE_INTEGER_LIST_ID = "@state6"; + public static final String STATE_INTEGER_LIST_NAME = "Integer List State"; + public static final String STATE_INTEGER_ID = "@state2"; public static final String STATE_INTEGER_NAME = "Integer State"; @@ -172,6 +175,15 @@ public class ModelGenerator { floatListTimedState.applyChange(new ValueChange<>(STATE_TIME_30, floatListValueChange), true); resource.addTimedState(floatListTimedState); + // integer list state + IntegerListTimedState intListTimedState = new IntegerListTimedState(STATE_INTEGER_LIST_ID, + STATE_INTEGER_LIST_NAME); + intListTimedState.applyChange(new ValueChange<>(STATE_TIME_0, new IntegerListValue(STATE_INTEGER_TIME_0)), + true); + IntegerListValue intListValueChange = new IntegerListValue(STATE_INTEGER_TIME_10, STATE_INTEGER_TIME_20); + intListTimedState.applyChange(new ValueChange<>(STATE_TIME_30, intListValueChange), true); + resource.addTimedState(intListTimedState); + // integer state IntegerTimedState integerTimedState = new IntegerTimedState(STATE_INTEGER_ID, STATE_INTEGER_NAME); integerTimedState.applyChange(new ValueChange<>(STATE_TIME_0, new IntegerValue(STATE_INTEGER_TIME_0)), true); @@ -444,8 +456,6 @@ public class ModelGenerator { *
  • DateParameter - 1354295525628L
  • *
  • StringListParameter - Hello, World
  • * - * - * @param bag */ public static void addAllParameters(ParameterBag bag) { diff --git a/li.strolch.model/src/main/java/li/strolch/model/StrolchValueType.java b/li.strolch.model/src/main/java/li/strolch/model/StrolchValueType.java index 1871a6597..c3ebcb041 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/StrolchValueType.java +++ b/li.strolch.model/src/main/java/li/strolch/model/StrolchValueType.java @@ -416,14 +416,12 @@ public enum StrolchValueType { @Override public StrolchTimedState> timedStateInstance() { - throw new UnsupportedOperationException( - MessageFormat.format("TimeStates of type {0} are not supported!", getType())); //$NON-NLS-1$ + return new IntegerListTimedState(); } @Override public IValue valueInstance(String valueAsString) { - throw new UnsupportedOperationException( - MessageFormat.format("Parameters of type {0} are not supported!", getType())); //$NON-NLS-1$ + return new IntegerListValue(valueAsString); } }, diff --git a/li.strolch.model/src/main/java/li/strolch/model/builder/ResourceBuilder.java b/li.strolch.model/src/main/java/li/strolch/model/builder/ResourceBuilder.java index e7fa809ab..3901120cc 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/builder/ResourceBuilder.java +++ b/li.strolch.model/src/main/java/li/strolch/model/builder/ResourceBuilder.java @@ -54,6 +54,12 @@ public class ResourceBuilder extends RootElementBuilder { return builder; } + public IntegerListStateBuilder integerListState(String id, String name) { + IntegerListStateBuilder builder = new IntegerListStateBuilder(this, id, name); + this.timedStates.add(builder); + return builder; + } + public StringSetStateBuilder stringSetState(String id, String name) { StringSetStateBuilder builder = new StringSetStateBuilder(this, id, name); this.timedStates.add(builder); diff --git a/li.strolch.model/src/main/java/li/strolch/model/builder/states/IntegerListStateBuilder.java b/li.strolch.model/src/main/java/li/strolch/model/builder/states/IntegerListStateBuilder.java new file mode 100644 index 000000000..cb1351368 --- /dev/null +++ b/li.strolch.model/src/main/java/li/strolch/model/builder/states/IntegerListStateBuilder.java @@ -0,0 +1,20 @@ +package li.strolch.model.builder.states; + +import li.strolch.model.builder.ResourceBuilder; +import li.strolch.model.timedstate.IntegerListTimedState; +import li.strolch.model.timevalue.impl.IntegerListValue; + +public class IntegerListStateBuilder extends TimedStateBuilder { + + public IntegerListStateBuilder(ResourceBuilder builder, String id, String name) { + super(builder, id, name); + } + + @Override + public IntegerListTimedState build() { + IntegerListTimedState state = new IntegerListTimedState(); + build(state); + state.getTimeEvolution().setValueAt(0L, new IntegerListValue()); + return state; + } +} diff --git a/li.strolch.model/src/main/java/li/strolch/model/json/StrolchElementToJsonVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/json/StrolchElementToJsonVisitor.java index 68b4f3e75..4a121fb37 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/json/StrolchElementToJsonVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/json/StrolchElementToJsonVisitor.java @@ -355,6 +355,13 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor { * * @return true if this element is read only */ - public boolean isReadonly(); + boolean isReadonly(); /** * Sets this element to readOnly, so that it may not be modified. To modify it, call getClone() on the * parent */ - public void setReadonly(); + void setReadonly(); } diff --git a/li.strolch.model/src/main/java/li/strolch/model/timedstate/IntegerListTimedState.java b/li.strolch.model/src/main/java/li/strolch/model/timedstate/IntegerListTimedState.java new file mode 100644 index 000000000..b478c948d --- /dev/null +++ b/li.strolch.model/src/main/java/li/strolch/model/timedstate/IntegerListTimedState.java @@ -0,0 +1,62 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.model.timedstate; + +import li.strolch.model.StrolchValueType; +import li.strolch.model.timevalue.impl.IntegerListValue; +import li.strolch.model.visitor.StrolchElementVisitor; + +/** + * @author Robert von Burg + */ +public class IntegerListTimedState extends AbstractStrolchTimedState { + + public IntegerListTimedState() { + super(); + } + + public IntegerListTimedState(String id, String name) { + super(id, name); + } + + @Override + public void setStateFromStringAt(Long time, String value) { + assertNotReadonly(); + getTimeEvolution().setValueAt(time, new IntegerListValue(value)); + } + + @Override + public String getType() { + return StrolchValueType.INTEGER_LIST.getType(); + } + + @Override + public StrolchValueType getValueType() { + return StrolchValueType.INTEGER_LIST; + } + + @Override + public U accept(StrolchElementVisitor visitor) { + return visitor.visitIntegerListState(this); + } + + @Override + public IntegerListTimedState getClone() { + IntegerListTimedState clone = new IntegerListTimedState(); + fillClone(clone); + return clone; + } +} diff --git a/li.strolch.model/src/main/java/li/strolch/model/timedstate/TimedState.java b/li.strolch.model/src/main/java/li/strolch/model/timedstate/TimedState.java index 6dbc6d1b0..a4efde255 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/timedstate/TimedState.java +++ b/li.strolch.model/src/main/java/li/strolch/model/timedstate/TimedState.java @@ -15,9 +15,6 @@ */ package li.strolch.model.timedstate; -import static java.util.Spliterators.spliteratorUnknownSize; -import static java.util.stream.StreamSupport.stream; - import java.io.Serializable; import java.util.NavigableSet; diff --git a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/FloatListValue.java b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/FloatListValue.java index 0cdf37c58..9d826e96a 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/FloatListValue.java +++ b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/FloatListValue.java @@ -34,7 +34,7 @@ public class FloatListValue implements IValue>, Serializable { public static final FloatListValue NEUTRAL = new FloatListValue(0.0d); - private List value; + private final List value; public FloatListValue(Double value) { this.value = Collections.singletonList(value); diff --git a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/IntegerListValue.java b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/IntegerListValue.java new file mode 100644 index 000000000..105b47412 --- /dev/null +++ b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/IntegerListValue.java @@ -0,0 +1,166 @@ +/* + * Copyright 2022 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.model.timevalue.impl; + +import static li.strolch.model.parameter.ListParameter.VALUE_SEPARATOR2; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import li.strolch.model.StrolchValueType; +import li.strolch.model.timevalue.ITimeValue; +import li.strolch.model.timevalue.IValue; +import li.strolch.utils.helper.StringHelper; + +/** + * {@link IValue} implementation to work with Integer valued {@link ITimeValue} objects + * + * @author Robert von Burg + */ +public class IntegerListValue implements IValue>, Serializable { + + public static final IntegerListValue NEUTRAL = new IntegerListValue(0); + + private final List value; + + public IntegerListValue(Integer value) { + this.value = Collections.singletonList(value); + } + + public IntegerListValue(int... values) { + List value = new ArrayList<>(); + for (Integer aInteger : values) { + value.add(aInteger); + } + this.value = value; + } + + public IntegerListValue(List values) { + this.value = new ArrayList<>(values); + } + + public IntegerListValue(String valueAsString) throws NumberFormatException { + List value = new ArrayList<>(); + String[] values = valueAsString.split(","); + for (String s : values) { + value.add(Integer.parseInt(s.trim())); + } + this.value = value; + } + + @Override + public String getType() { + return StrolchValueType.INTEGER_LIST.getType(); + } + + @Override + public IntegerListValue add(List o) { + this.value.addAll(o); + return this; + } + + @Override + public List getValue() { + return this.value; + } + + @Override + public String getValueAsString() { + if (this.value.isEmpty()) { + return StringHelper.EMPTY; + } + + StringBuilder sb = new StringBuilder(); + Iterator iter = this.value.iterator(); + while (iter.hasNext()) { + + sb.append(iter.next()); + + if (iter.hasNext()) { + sb.append(VALUE_SEPARATOR2); + sb.append(" "); + } + } + + return sb.toString(); + } + + @SuppressWarnings("nls") + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("IntegerListValue [value="); + sb.append(this.value); + sb.append("]"); + return sb.toString(); + } + + @Override + public boolean matches(IValue> other) { + return this.value.equals(other.getValue()); + } + + @Override + public IntegerListValue getInverse() { + return new IntegerListValue(this.value); + } + + @Override + public IntegerListValue getCopy() { + return new IntegerListValue(this.value); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.value == null) ? 0 : this.value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + IntegerListValue other = (IntegerListValue) obj; + if (this.value == null) { + if (other.value != null) { + return false; + } + } else if (!this.value.equals(other.value)) { + return false; + } + return true; + } + + @Override + public int compareTo(IValue> o) { + List otherValues = o.getValue(); + if (this.value.equals(otherValues)) + return 0; + return Integer.compare(this.value.size(), otherValues.size()); + } +} diff --git a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/StringSetValue.java b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/StringSetValue.java index 9d7c6a958..be101b41c 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/StringSetValue.java +++ b/li.strolch.model/src/main/java/li/strolch/model/timevalue/impl/StringSetValue.java @@ -36,7 +36,7 @@ import li.strolch.utils.helper.StringHelper; */ public class StringSetValue implements IValue>, Serializable { - private static Set neu = Collections.emptySet(); + private final static Set neu = Collections.emptySet(); public static final IValue> NEUTRAL = new StringSetValue(neu); private Set aStrings = new HashSet<>(); diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/ActivityVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/ActivityVisitor.java index d1e85f835..9a8b75ae4 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/ActivityVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/ActivityVisitor.java @@ -17,15 +17,8 @@ package li.strolch.model.visitor; import li.strolch.model.Order; import li.strolch.model.Resource; -import li.strolch.model.parameter.*; -import li.strolch.model.timedstate.FloatListTimedState; -import li.strolch.model.timedstate.FloatTimedState; -import li.strolch.model.timedstate.IntegerTimedState; -import li.strolch.model.timedstate.StringSetTimedState; /** - * @param - * * @author Robert von Burg */ public interface ActivityVisitor extends StrolchRootElementVisitor { @@ -39,79 +32,4 @@ public interface ActivityVisitor extends StrolchRootElementVisitor { default U visitResource(Resource resource) { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + resource.getClass()); } - - @Override - default U visitBooleanParam(BooleanParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitDateParam(DateParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitDurationParam(DurationParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitFloatParam(FloatParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitIntegerParam(IntegerParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitLongParam(LongParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitStringParam(StringParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitStringListParam(StringListParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitIntegerListParam(IntegerListParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitFloatListParam(FloatListParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitLongListParam(LongListParameter param) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + param.getClass()); - } - - @Override - default U visitFloatState(FloatTimedState state) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); - } - - @Override - default U visitFloatListState(FloatListTimedState state) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); - } - - @Override - default U visitIntegerState(IntegerTimedState state) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); - } - - @Override - default U visitStringState(StringSetTimedState state) { - throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); - } } diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/IActivityElementVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/IActivityElementVisitor.java index 20cf90675..fb177bcdb 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/IActivityElementVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/IActivityElementVisitor.java @@ -93,6 +93,11 @@ public interface IActivityElementVisitor extends StrolchElementVisitor { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); } + @Override + default U visitIntegerListState(IntegerListTimedState state) { + throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); + } + @Override default U visitIntegerState(IntegerTimedState state) { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/ParameterVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/ParameterVisitor.java index b18b8e4c5..b0807f35b 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/ParameterVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/ParameterVisitor.java @@ -62,6 +62,11 @@ public interface ParameterVisitor extends StrolchElementVisitor { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); } + @Override + default U visitIntegerListState(IntegerListTimedState state) { + throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); + } + @Override default U visitIntegerState(IntegerTimedState state) { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/SetStateValueVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/SetStateValueVisitor.java index 0d586680a..ab7e3f2dd 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/SetStateValueVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/SetStateValueVisitor.java @@ -58,6 +58,13 @@ public class SetStateValueVisitor implements TimedStateVisitor { return null; } + @SuppressWarnings("unchecked") + @Override + public Void visitIntegerListState(IntegerListTimedState state) { + state.getTimeEvolution().setValueAt(this.time, new IntegerListValue((List) value)); + return null; + } + @Override public Void visitIntegerState(IntegerTimedState state) { state.getTimeEvolution().setValueAt(this.time, new IntegerValue((Integer) value)); diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementDeepEqualsVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementDeepEqualsVisitor.java index 7fdc3fccc..3b16a1c6a 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementDeepEqualsVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementDeepEqualsVisitor.java @@ -344,161 +344,168 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor
  • visitOrder(Order order) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), order.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), order.getClass()); deepEquals((Order) this.srcElement, order); return getMismatchedLocators(); } @Override public List visitResource(Resource resource) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), resource.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), resource.getClass()); deepEquals((Resource) this.srcElement, resource); return getMismatchedLocators(); } @Override public List visitActivity(Activity activity) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), activity.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), activity.getClass()); deepEquals((Activity) this.srcElement, activity); return getMismatchedLocators(); } @Override public List visitAction(Action action) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), action.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), action.getClass()); deepEquals((Action) this.srcElement, action); return getMismatchedLocators(); } @Override public List visitBooleanParam(BooleanParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitDateParam(DateParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitDurationParam(DurationParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitFloatParam(FloatParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitIntegerParam(IntegerParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitLongParam(LongParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitStringParam(StringParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitTextParam(TextParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitStringListParam(StringListParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitIntegerListParam(IntegerListParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitFloatListParam(FloatListParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitLongListParam(LongListParameter param) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), param.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), param.getClass()); deepEquals((Parameter) this.srcElement, param); return getMismatchedLocators(); } @Override public List visitBooleanState(BooleanTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitFloatState(FloatTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitFloatListState(FloatListTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); + deepEquals((StrolchTimedState) this.srcElement, state); + return getMismatchedLocators(); + } + + @Override + public List visitIntegerListState(IntegerListTimedState state) { + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitIntegerState(IntegerTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitLongState(LongTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitStringState(StringSetTimedState state) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), state.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), state.getClass()); deepEquals((StrolchTimedState) this.srcElement, state); return getMismatchedLocators(); } @Override public List visitParameterBag(ParameterBag bag) { - DBC.PRE.assertEquals("Can't compare apples with pairs =)", this.srcElement.getClass(), bag.getClass()); + DBC.PRE.assertEquals("Can't compare apples with pears =)", this.srcElement.getClass(), bag.getClass()); deepEquals((ParameterBag) this.srcElement, bag); return getMismatchedLocators(); } diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementVisitor.java index e1fd784c8..33cc85469 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchElementVisitor.java @@ -68,6 +68,8 @@ public interface StrolchElementVisitor extends StrolchVisitor { U visitFloatListState(FloatListTimedState state); + U visitIntegerListState(IntegerListTimedState state); + U visitIntegerState(IntegerTimedState state); U visitStringState(StringSetTimedState state); diff --git a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchRootElementVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchRootElementVisitor.java index f20e2051f..2f6be3f46 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchRootElementVisitor.java +++ b/li.strolch.model/src/main/java/li/strolch/model/visitor/StrolchRootElementVisitor.java @@ -105,6 +105,11 @@ public interface StrolchRootElementVisitor extends StrolchElementVisitor { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); } + @Override + default U visitIntegerListState(IntegerListTimedState state) { + throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); + } + @Override default U visitIntegerState(IntegerTimedState state) { throw new UnsupportedOperationException(getClass().getName() + " can not handle " + state.getClass()); diff --git a/li.strolch.model/src/test/java/li/strolch/model/ModelTest.java b/li.strolch.model/src/test/java/li/strolch/model/ModelTest.java index 6d57a3990..d6136faf3 100644 --- a/li.strolch.model/src/test/java/li/strolch/model/ModelTest.java +++ b/li.strolch.model/src/test/java/li/strolch/model/ModelTest.java @@ -506,6 +506,14 @@ public class ModelTest { assertEquals(asList(STATE_FLOAT_TIME_0, STATE_FLOAT_TIME_10, STATE_FLOAT_TIME_20), floatListState.getStateAt(STATE_TIME_30).getValue().getValue()); + IntegerListTimedState intListState = resource.getTimedState(STATE_INTEGER_LIST_ID); + assertNotNull("Integer List State missing with id " + STATE_INTEGER_ID, intListState); + assertEquals(singletonList(STATE_INTEGER_TIME_0), intListState.getStateAt(STATE_TIME_0).getValue().getValue()); + assertEquals(singletonList(STATE_INTEGER_TIME_0), intListState.getStateAt(STATE_TIME_10).getValue().getValue()); + assertEquals(singletonList(STATE_INTEGER_TIME_0), intListState.getStateAt(STATE_TIME_20).getValue().getValue()); + assertEquals(asList(STATE_INTEGER_TIME_0, STATE_INTEGER_TIME_10, STATE_INTEGER_TIME_20), + intListState.getStateAt(STATE_TIME_30).getValue().getValue()); + IntegerTimedState integerState = resource.getTimedState(STATE_INTEGER_ID); assertNotNull("Integer State missing with id " + STATE_INTEGER_ID, integerState); assertEquals(STATE_INTEGER_TIME_0, integerState.getStateAt(STATE_TIME_0).getValue().getValue(), 0.0);