public class BitDistance extends NumberDistance<BitDistance,Bit>
Modifier and Type | Field and Description |
---|---|
static BitDistance |
FACTORY
The static factory instance
|
private static long |
serialVersionUID
Generated serial version UID
|
private boolean |
value
The distance value
|
DOUBLE_PATTERN, INFINITY_PATTERN, INTEGER_PATTERN
Constructor and Description |
---|
BitDistance()
Empty constructor for serialization purposes.
|
BitDistance(Bit bit)
Constructs a new BitDistance object that represents the bit argument.
|
BitDistance(boolean bit)
Constructs a new BitDistance object that represents the bit argument.
|
Modifier and Type | Method and Description |
---|---|
boolean |
bitValue()
Returns the value of this BitDistance as a boolean.
|
int |
compareTo(BitDistance other)
Compares this NumberDistance with the given NumberDistance wrt the
represented value.
|
double |
doubleValue()
Get the value as double.
|
int |
externalizableSize()
Returns the number of Bytes this distance uses if it is written to an
external file.
|
BitDistance |
fromDouble(double val)
Build a new instance from a double value.
|
Pattern |
getPattern()
Get the pattern accepted by this distance
|
Bit |
getValue()
Returns the value of this NumberDistance.
|
BitDistance |
infiniteDistance()
Provides an infinite distance.
|
int |
intValue()
Get the value as int.
|
boolean |
isInfiniteDistance()
Returns true, if the distance is an infinite distance, false otherwise.
|
boolean |
isNullDistance()
Returns true, if the distance is a null distance, false otherwise.
|
boolean |
isUndefinedDistance()
Returns true, if the distance is an undefined distance, false otherwise.
|
long |
longValue()
Get the value as long.
|
BitDistance |
minus(BitDistance distance)
Returns a new Distance by subtracting the given distance from this
distance.
|
BitDistance |
nullDistance()
Provides a null distance.
|
BitDistance |
parseString(String val)
Provides a measurement suitable to this measurement function based on the
given pattern.
|
BitDistance |
plus(BitDistance distance)
Returns a new distance as sum of this distance and the given distance.
|
void |
readExternal(ObjectInput in)
Reads the bit value of this BitDistance from the specified stream.
|
(package private) void |
setValue(Bit value)
Sets the value of this NumberDistance.
|
BitDistance |
undefinedDistance()
Provides an undefined distance.
|
void |
writeExternal(ObjectOutput out)
Writes the bit value of this BitDistance to the specified stream.
|
byteValue, floatValue, hashCode, shortValue, toString
equals, requiredInputPattern, testInputPattern
public static final BitDistance FACTORY
private boolean value
private static final long serialVersionUID
public BitDistance()
public BitDistance(boolean bit)
bit
- the value to be represented by the BitDistance.public BitDistance(Bit bit)
bit
- the value to be represented by the BitDistance.public BitDistance fromDouble(double val)
NumberDistance
fromDouble
in class NumberDistance<BitDistance,Bit>
val
- Valuepublic BitDistance plus(BitDistance distance)
Distance
distance
- the distance to be added to this distancepublic BitDistance minus(BitDistance distance)
Distance
distance
- the distance to be subtracted from this distancepublic boolean bitValue()
public void writeExternal(ObjectOutput out) throws IOException
IOException
public void readExternal(ObjectInput in) throws IOException
IOException
public int externalizableSize()
public Bit getValue()
NumberDistance
getValue
in class NumberDistance<BitDistance,Bit>
void setValue(Bit value)
NumberDistance
setValue
in class NumberDistance<BitDistance,Bit>
value
- the value to be setpublic double doubleValue()
NumberDistance
doubleValue
in class NumberDistance<BitDistance,Bit>
public long longValue()
NumberDistance
longValue
in class NumberDistance<BitDistance,Bit>
public int intValue()
NumberDistance
intValue
in class NumberDistance<BitDistance,Bit>
public int compareTo(BitDistance other)
NumberDistance
d1.compareTo(d2)
is the same as
Double.compare(d1.value.doubleValue(),
d2.value.doubleValue())
. Subclasses may need to overwrite this method if
necessary.compareTo
in interface Comparable<BitDistance>
compareTo
in class NumberDistance<BitDistance,Bit>
other
- Other objectpublic BitDistance parseString(String val) throws IllegalArgumentException
Distance
val
- a pattern defining a similarity suitable to this measurement
functionIllegalArgumentException
- if the given pattern is not compatible
with the requirements of this measurement functionpublic BitDistance infiniteDistance()
Distance
public BitDistance nullDistance()
Distance
public BitDistance undefinedDistance()
Distance
public Pattern getPattern()
AbstractDistance
getPattern
in class AbstractDistance<BitDistance>
public boolean isInfiniteDistance()
Distance
isInfiniteDistance
in interface Distance<BitDistance>
isInfiniteDistance
in class AbstractDistance<BitDistance>
public boolean isNullDistance()
Distance
isNullDistance
in interface Distance<BitDistance>
isNullDistance
in class AbstractDistance<BitDistance>
public boolean isUndefinedDistance()
Distance
isUndefinedDistance
in interface Distance<BitDistance>
isUndefinedDistance
in class AbstractDistance<BitDistance>