Class AbsoluteOrRelativeInt
java.lang.Object
ch.nolix.system.element.base.AbstractElement
ch.nolix.system.element.relativevalue.AbsoluteOrRelativeInt
- All Implemented Interfaces:
IElement, IAbsoluteOrRelativeInt
A
AbsoluteOrRelativeInt stores either an integer or a percentage. A
AbsoluteOrRelativeInt is not mutable.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionstatic AbsoluteOrRelativeIntfromSpecification(INode<?> specification) intIContainer<INode<?>> doubleintgetValueRelativeToHundredPercentValue(int hundredPercentValue) booleanbooleanbooleanstatic AbsoluteOrRelativeIntwithIntValue(int intValue) static AbsoluteOrRelativeIntwithPercentage(double percentage) Methods inherited from class AbstractElement
equals, getSpecification, hashCode, toStringMethods inherited from interface IElement
getSpecification, toFormatedString, toXml
-
Method Details
-
fromSpecification
- Parameters:
specification-- Returns:
- a new
AbsoluteOrRelativeIntfrom the given specification. - Throws:
RuntimeException- if the given specification is not valid.
-
withIntValue
- Parameters:
intValue-- Returns:
- a new
AbsoluteOrRelativeIntwith the given intValue.
-
withPercentage
- Parameters:
percentage-- Returns:
- a new
AbsoluteOrRelativeIntwith the given percentage. - Throws:
RuntimeException- if the given percentage is negative.
-
getAttributes
- Specified by:
getAttributesin interfaceIElement- Returns:
- the attributes of the current
IElement.
-
getAbsoluteValue
public int getAbsoluteValue()- Specified by:
getAbsoluteValuein interfaceIAbsoluteOrRelativeInt- Returns:
- the absolute value of the current
IAbsoluteOrRelativeInt.
-
getPercentage
public double getPercentage()- Specified by:
getPercentagein interfaceIAbsoluteOrRelativeInt- Returns:
- the percentage of the current
IAbsoluteOrRelativeInt.
-
getValueRelativeToHundredPercentValue
public int getValueRelativeToHundredPercentValue(int hundredPercentValue) - Specified by:
getValueRelativeToHundredPercentValuein interfaceIAbsoluteOrRelativeInt- Parameters:
hundredPercentValue-- Returns:
- the value of the current
IAbsoluteOrRelativeIntrelative to the given hundredPercentValue.
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfaceIAbsoluteOrRelativeInt- Returns:
- true if the current
IAbsoluteOrRelativeIntis absolute, false otherwise.
-
isPositive
public boolean isPositive()- Specified by:
isPositivein interfaceIAbsoluteOrRelativeInt- Returns:
- true if the current
IAbsoluteOrRelativeIntis positive, false otherwise.
-
isRelative
public boolean isRelative()- Specified by:
isRelativein interfaceIAbsoluteOrRelativeInt- Returns:
- true if the current
IAbsoluteOrRelativeIntis relative, false otherwise.
-