org.hd.d.pg2k.svrCore.location
Class Location.ValueAndBounds

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.location.Location.ValueAndBounds
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Location.DoubleValueAndBounds, Location.LongValueAndBounds
Enclosing class:
Location

public abstract static class Location.ValueAndBounds
extends java.lang.Object
implements java.io.Serializable

Base class of location value with error bounds. The value is the mid-point of range of the value, and the error is the width of the interval, ON EITHER SIDE OF the value (the mid-point), encompassing both any actual `duration' or `size' of the item and any error or uncertainty in the value. Thus the value can be shown as +/- the error.

The error values returned must always be non-negative (zero is allowed).

This abstract class can be derived to store the units in various forms. All derived classes must be immutable, so we will only allow it to be constructed by well-behaved sub-classes that use guaranteed-immutable Number args, and that also ensure that the error value is non-negative.

This and any deriving classes should be immutable, serialisable, and support equals() and hashCode().

TODO: should validate on deserialisation.

See Also:
Serialized Form

Field Summary
 java.lang.Number error
          Error bounds; never null.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
 java.lang.Number value
          Central value; never null.
 
Constructor Summary
Location.ValueAndBounds(java.lang.Number v, java.lang.Number e)
          Construct a new value.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Depends on equality of value and error.
 int hashCode()
          Currently depends on only value for speed.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

public final java.lang.Number value
Central value; never null.


error

public final java.lang.Number error
Error bounds; never null.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

Location.ValueAndBounds

Location.ValueAndBounds(java.lang.Number v,
                        java.lang.Number e)
Construct a new value. The constructor visibility limits deriving classes to this package. This helps ensure that we can guarantee features sush as immutability.

Method Detail

hashCode

public int hashCode()
Currently depends on only value for speed.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Depends on equality of value and error.

Overrides:
equals in class java.lang.Object

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.