Merge branch 'master' of github.com:eitch/li.strolch.model

This commit is contained in:
Robert von Burg 2013-08-12 18:10:53 +02:00
commit 618369378e
13 changed files with 64 additions and 24 deletions

View File

@ -8,7 +8,7 @@ import li.strolch.model.timevalue.IValueChange;
/**
* A time based state characterized by a {@link IValue} object implementation.
*
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*
* @param <T>
* IValue implementation representing the state at a given time

View File

@ -1,5 +1,6 @@
package li.strolch.model.timedstate;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
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.impl.TimeVariable;
/**
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*/
@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>();
@Override

View File

@ -5,7 +5,7 @@ import li.strolch.model.timevalue.impl.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>
* the backing value of the timed value object

View File

@ -1,12 +1,13 @@
package li.strolch.model.timevalue;
import java.util.Collection;
import java.util.SortedSet;
/**
* A timed variable storing a ordered sequence of {@link ITimeValue} objects
* modeling a time evolution of a quantity.
*
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*
* @param <T>
* 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);
/**
* 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
* matches value. I.e considering a pair of adjacent {@link ITimeValue}

View File

@ -4,7 +4,7 @@ package li.strolch.model.timevalue;
* A value object defining some basic algebraic operations. Mathematically
* speaking {@link IValue} objects define a group with a addition operation.
*
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*
* @param <T>
* any object for which a (generalized) add operation can be defined.

View File

@ -4,7 +4,7 @@ package li.strolch.model.timevalue;
* Interface for operators to be used to change the values of {@link ITimeValue}
* in a {@link ITimeVariable}.
*
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*/
@SuppressWarnings("rawtypes")
public interface IValueChange<T extends IValue> {

View File

@ -1,13 +1,17 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
/**
* Wrapper for java.util.String object defining a inverse to support algebraic
* 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 boolean inverse;

View File

@ -1,14 +1,18 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.IValue;
/**
* {@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);

View File

@ -1,5 +1,7 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import li.strolch.model.timevalue.ITimeValue;
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}
* 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);

View File

@ -1,5 +1,6 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@ -8,15 +9,16 @@ import java.util.Set;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.IValue;
/**
* {@link IValue} implementation to work with String valued {@link ITimeValue}
* objects. Since a java.util.String object does not define a inverse, a
* 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();
public static final IValue<Set<AString>> NEUTRAL = new StringSetValue(neu);

View File

@ -1,13 +1,17 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import li.strolch.model.timevalue.ITimeValue;
import li.strolch.model.timevalue.IValue;
/**
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*/
@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 T value;

View File

@ -1,5 +1,6 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
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")
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>>();
@Override
@ -53,6 +56,11 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T> {
TimeValue<T> picker = new TimeValue<T>(time, null);
return new TreeSet<ITimeValue<T>>(container.headSet(picker));
}
@Override
public SortedSet<ITimeValue<T>> getValues() {
return new TreeSet<ITimeValue<T>>(container);
}
@Override
public void applyChange(final IValueChange<T> change) {

View File

@ -1,14 +1,18 @@
package li.strolch.model.timevalue.impl;
import java.io.Serializable;
import li.strolch.model.timevalue.IValue;
import li.strolch.model.timevalue.IValueChange;
/**
* @author martin_smock
* @author Martin Smock <smock.martin@gmail.com>
*/
@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 T value;