Package de.timmfitschen.easyunits
Class Unit
- java.lang.Object
-
- de.timmfitschen.easyunits.UniqueSignatureObject
-
- de.timmfitschen.easyunits.Named
-
- de.timmfitschen.easyunits.Symboled
-
- de.timmfitschen.easyunits.Unit
-
- All Implemented Interfaces:
Signed
- Direct Known Subclasses:
BaseUnit
,CompoundUnit
,ConvertedUnit
public abstract class Unit extends Symboled
-
-
Constructor Summary
Constructors Constructor Description Unit()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Unit
add(Number n)
CompoundUnit
divide(Unit u)
Unit
divide(Number n)
abstract Converter
getConverter()
Return a converter for a conversion of this unit to the normalized unit.abstract Unit
getNormalizedUnit()
Calculate the base unit or a compound unit that consists of base units only, without any prefixes.String
getPrefixableBy()
int
hashCode()
boolean
isNormal()
Returns true iff this unit is normal.boolean
isPrefixableBy(Prefix p)
Unit
power(int i)
Unit
setPrefixableBy(String prefixes)
CompoundUnit
times(Unit u)
Unit
times(Number n)
protected Unit
transform(Converter c)
Transform this unit into another by means of a converter.-
Methods inherited from class de.timmfitschen.easyunits.UniqueSignatureObject
equals
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.timmfitschen.easyunits.Signed
getSignature
-
-
-
-
Field Detail
-
ONE
public static final BaseUnit ONE
-
-
Method Detail
-
isNormal
public final boolean isNormal()
Returns true iff this unit is normal. I.e. this unit is a BaseUnit or a CompoundUnit which consists only of BaseUnits.- Returns:
- true iff this unit is normal.
-
getNormalizedUnit
public abstract Unit getNormalizedUnit()
Calculate the base unit or a compound unit that consists of base units only, without any prefixes. This is the target unit of the converter.- Returns:
- base unit/compound of base units.
-
getConverter
public abstract Converter getConverter()
Return a converter for a conversion of this unit to the normalized unit.- Returns:
-
transform
protected Unit transform(Converter c)
Transform this unit into another by means of a converter. That is basically a way of defining a new unit. E.g.Unit degree_celcius = kelvin.transform(new AddConverter(-273.15));
The converter defines the function which converts a value of the new unit into this unit.- Parameters:
c
-- Returns:
-
times
public CompoundUnit times(Unit u)
-
power
public Unit power(int i)
-
divide
public CompoundUnit divide(Unit u)
-
getPrefixableBy
public String getPrefixableBy()
-
isPrefixableBy
public boolean isPrefixableBy(Prefix p)
-
-