org.robokind.api.common.position
Class NormalizedDouble

java.lang.Object
  extended by org.robokind.api.common.position.NormalizedDouble
All Implemented Interfaces:
Cloneable, Comparable

public class NormalizedDouble
extends Object
implements Comparable, Cloneable

NormalizedDouble is a value normalized to the range of [0.0, 1.0] (0.0 <= val <= 1.0). The value is stored as a Double. When creating a NormalizedDouble, the value is checked to ensure it is within the range of [0.0, 1.0] and throws an IllegalArgumentException if invalid.

Author:
Matthew Stevenson

Constructor Summary
NormalizedDouble(double value)
          Creates a new NormalizedDouble with the given value
 
Method Summary
 Object clone()
           
 int compareTo(Object o)
           
 boolean equals(Object obj)
           
 double getValue()
          Returns the value of the NormalizeRange.
 int hashCode()
           
static boolean isValid(double value)
          Returns true if the given value can be used to create a NormalizedDouble.
protected  void rangeCheck(double value)
          Checks that the value is within the range [0.0, 1.0].
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NormalizedDouble

public NormalizedDouble(double value)
Creates a new NormalizedDouble with the given value

Parameters:
value - the value to set
Throws:
IllegalArgumentException - if value is not in the range [0.0, 1.0]
Method Detail

getValue

public double getValue()
Returns the value of the NormalizeRange.

Returns:
the value of the NormalizeRange

rangeCheck

protected final void rangeCheck(double value)
Checks that the value is within the range [0.0, 1.0].

Parameters:
value - the value to check
Throws:
IllegalArgumentException - if value is not in the range [0.0,1.0]

isValid

public static boolean isValid(double value)
Returns true if the given value can be used to create a NormalizedDouble. A valid value is in the range [0.0, 1.0]

Parameters:
value - the value to test
Returns:
true if the given value can be used to create a NormalizedDouble

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2011-2013. All Rights Reserved.