Merge branch 'master' of github.com:eitch/li.strolch.model
This commit is contained in:
commit
618369378e
|
@ -8,7 +8,7 @@ import li.strolch.model.timevalue.IValueChange;
|
||||||
/**
|
/**
|
||||||
* A time based state characterized by a {@link IValue} object implementation.
|
* A time based state characterized by a {@link IValue} object implementation.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* IValue implementation representing the state at a given time
|
* IValue implementation representing the state at a given time
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package li.strolch.model.timedstate;
|
package li.strolch.model.timedstate;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -11,13 +12,14 @@ import li.strolch.model.timevalue.IValue;
|
||||||
import li.strolch.model.timevalue.IValueChange;
|
import li.strolch.model.timevalue.IValueChange;
|
||||||
import li.strolch.model.timevalue.impl.TimeVariable;
|
import li.strolch.model.timevalue.impl.TimeVariable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class TimedState<T extends IValue> implements ITimedState<T> {
|
public class TimedState<T extends IValue> implements ITimedState<T>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private ITimeVariable<T> timeVariable = new TimeVariable<T>();
|
private ITimeVariable<T> timeVariable = new TimeVariable<T>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,7 @@ import li.strolch.model.timevalue.impl.TimeVariable;
|
||||||
/**
|
/**
|
||||||
* Interface for timed value objects to be used with the {@link TimeVariable}
|
* Interface for timed value objects to be used with the {@link TimeVariable}
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* the backing value of the timed value object
|
* the backing value of the timed value object
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package li.strolch.model.timevalue;
|
package li.strolch.model.timevalue;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A timed variable storing a ordered sequence of {@link ITimeValue} objects
|
* A timed variable storing a ordered sequence of {@link ITimeValue} objects
|
||||||
* modeling a time evolution of a quantity.
|
* modeling a time evolution of a quantity.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* the backing value of the timed value object
|
* the backing value of the timed value object
|
||||||
|
@ -59,6 +60,13 @@ public interface ITimeVariable<T extends IValue> {
|
||||||
*/
|
*/
|
||||||
Collection<ITimeValue<T>> getPastValues(final Long time);
|
Collection<ITimeValue<T>> getPastValues(final Long time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all {@link ITimeValue} objects
|
||||||
|
*
|
||||||
|
* @return a defensive copy of the {@link ITimeValue}s
|
||||||
|
*/
|
||||||
|
SortedSet<ITimeValue<T>> getValues();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes {@link ITimeValue} objects from the sequence, where the successor
|
* removes {@link ITimeValue} objects from the sequence, where the successor
|
||||||
* matches value. I.e considering a pair of adjacent {@link ITimeValue}
|
* matches value. I.e considering a pair of adjacent {@link ITimeValue}
|
||||||
|
|
|
@ -4,7 +4,7 @@ package li.strolch.model.timevalue;
|
||||||
* A value object defining some basic algebraic operations. Mathematically
|
* A value object defining some basic algebraic operations. Mathematically
|
||||||
* speaking {@link IValue} objects define a group with a addition operation.
|
* speaking {@link IValue} objects define a group with a addition operation.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* any object for which a (generalized) add operation can be defined.
|
* any object for which a (generalized) add operation can be defined.
|
||||||
|
|
|
@ -4,7 +4,7 @@ package li.strolch.model.timevalue;
|
||||||
* Interface for operators to be used to change the values of {@link ITimeValue}
|
* Interface for operators to be used to change the values of {@link ITimeValue}
|
||||||
* in a {@link ITimeVariable}.
|
* in a {@link ITimeVariable}.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public interface IValueChange<T extends IValue> {
|
public interface IValueChange<T extends IValue> {
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for java.util.String object defining a inverse to support algebraic
|
* Wrapper for java.util.String object defining a inverse to support algebraic
|
||||||
* operations.
|
* operations.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class AString {
|
public class AString implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final String string;
|
private final String string;
|
||||||
private final boolean inverse;
|
private final boolean inverse;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link IValue} implementation to work with Double valued {@link ITimeValue} objects
|
* {@link IValue} implementation to work with Double valued {@link ITimeValue} objects
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class DoubleValue implements IValue<Double> {
|
public class DoubleValue implements IValue<Double>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final DoubleValue NEUTRAL = new DoubleValue(0.0d);
|
public static final DoubleValue NEUTRAL = new DoubleValue(0.0d);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
|
|
||||||
|
@ -7,9 +9,11 @@ import li.strolch.model.timevalue.IValue;
|
||||||
* {@link IValue} implementation to work with Integer valued {@link ITimeValue}
|
* {@link IValue} implementation to work with Integer valued {@link ITimeValue}
|
||||||
* objects
|
* objects
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class IntegerValue implements IValue<Integer> {
|
public class IntegerValue implements IValue<Integer>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final IntegerValue NEUTRAL = new IntegerValue(0);
|
public static final IntegerValue NEUTRAL = new IntegerValue(0);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -8,15 +9,16 @@ import java.util.Set;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link IValue} implementation to work with String valued {@link ITimeValue}
|
* {@link IValue} implementation to work with String valued {@link ITimeValue}
|
||||||
* objects. Since a java.util.String object does not define a inverse, a
|
* objects. Since a java.util.String object does not define a inverse, a
|
||||||
* algebraic {@link AString} wrapper is used.
|
* algebraic {@link AString} wrapper is used.
|
||||||
*
|
*
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class StringSetValue implements IValue<Set<AString>> {
|
public class StringSetValue implements IValue<Set<AString>>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static Set<AString> neu = Collections.emptySet();
|
private static Set<AString> neu = Collections.emptySet();
|
||||||
public static final IValue<Set<AString>> NEUTRAL = new StringSetValue(neu);
|
public static final IValue<Set<AString>> NEUTRAL = new StringSetValue(neu);
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class TimeValue<T extends IValue> implements ITimeValue <T> {
|
public class TimeValue<T extends IValue> implements ITimeValue <T>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected final Long time;
|
protected final Long time;
|
||||||
protected T value;
|
protected T value;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
@ -12,11 +13,13 @@ import li.strolch.model.timevalue.IValueChange;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class TimeVariable<T extends IValue> implements ITimeVariable<T> {
|
public class TimeVariable<T extends IValue> implements ITimeVariable<T>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public SortedSet<ITimeValue<T>> container = new TreeSet<ITimeValue<T>>();
|
public SortedSet<ITimeValue<T>> container = new TreeSet<ITimeValue<T>>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,6 +56,11 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T> {
|
||||||
TimeValue<T> picker = new TimeValue<T>(time, null);
|
TimeValue<T> picker = new TimeValue<T>(time, null);
|
||||||
return new TreeSet<ITimeValue<T>>(container.headSet(picker));
|
return new TreeSet<ITimeValue<T>>(container.headSet(picker));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<ITimeValue<T>> getValues() {
|
||||||
|
return new TreeSet<ITimeValue<T>>(container);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyChange(final IValueChange<T> change) {
|
public void applyChange(final IValueChange<T> change) {
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
import li.strolch.model.timevalue.IValueChange;
|
import li.strolch.model.timevalue.IValueChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author martin_smock
|
* @author Martin Smock <smock.martin@gmail.com>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class ValueChange<T extends IValue> implements IValueChange<T> {
|
public class ValueChange<T extends IValue> implements IValueChange<T>, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected final Long time;
|
protected final Long time;
|
||||||
protected final T value;
|
protected final T value;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue