JTemporal Home
Tutorial

net.sf.jtemporal
Class SimpleTimedObject<V>

java.lang.Object
  extended by net.sf.jtemporal.AbstractTimedObject<V>
      extended by net.sf.jtemporal.SimpleTimedObject<V>
Type Parameters:
V - the type of the value
All Implemented Interfaces:
TimedObject

public class SimpleTimedObject<V>
extends AbstractTimedObject<V>

Associates an Object to a Period. The semantics of the period is free. Is immutable when the value is immutable as well.

Version:
$Id: SimpleTimedObject.java,v 1.5 2007/09/23 20:07:52 tabeck Exp $

Constructor Summary
SimpleTimedObject(Period period, V value)
          Unique constructor initializing the final field.
 
Method Summary
 Period getPeriod()
          Must always return the same Period.
 V getValue()
          Must always return the same reference of value.
static TimedObject intersect(TimedObject to, Period p)
          Returns a new SimpleTimedObject representing the common part in the two periods.
 
Methods inherited from class net.sf.jtemporal.AbstractTimedObject
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTimedObject

public SimpleTimedObject(Period period,
                         V value)
Unique constructor initializing the final field.

Method Detail

getPeriod

public Period getPeriod()
Description copied from class: AbstractTimedObject
Must always return the same Period.

Specified by:
getPeriod in interface TimedObject
Specified by:
getPeriod in class AbstractTimedObject<V>
Returns:
the period associated to the value

getValue

public V getValue()
Description copied from class: AbstractTimedObject
Must always return the same reference of value.

Specified by:
getValue in interface TimedObject
Specified by:
getValue in class AbstractTimedObject<V>
Returns:
the value

intersect

public static TimedObject intersect(TimedObject to,
                                    Period p)
Returns a new SimpleTimedObject representing the common part in the two periods.
Note: returns null if this.getPeriod().overlaps(p) == false

Parameters:
to - the TimedObject to be intersected, whose value is returned
p - the Period to be intersected
Returns:
a new SimpleTimedObject whose validity is the intersection of both periods, or null if the intersection is null.

JTemporal Home
Tutorial