Package com.helger.css.propertyvalue
Class CSSSimpleValueWithUnit
- java.lang.Object
-
- com.helger.css.propertyvalue.CSSSimpleValueWithUnit
-
-
Constructor Summary
Constructors Constructor Description CSSSimpleValueWithUnit(double dValue, ECSSUnit eUnit)
ConstructorCSSSimpleValueWithUnit(BigDecimal aValue, ECSSUnit eUnit)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSSimpleValueWithUnit
add(double dDelta)
Get a new object with the same unit but an added value.CSSSimpleValueWithUnit
add(BigDecimal aDelta)
Get a new object with the same unit but an added value.CSSSimpleValueWithUnit
divide(double dDivisor)
Get a new object with the same unit but an divided value.CSSSimpleValueWithUnit
divide(BigDecimal aDivisor)
Get a new object with the same unit but an divided value.CSSSimpleValueWithUnit
divide(BigDecimal aDivisor, int nScale, RoundingMode eRoundingMode)
Get a new object with the same unit but an divided value.boolean
equals(Object o)
BigDecimal
getAsBigDecimalValue()
int
getAsIntValue()
long
getAsLongValue()
String
getFormatted()
ECSSUnit
getUnit()
double
getValue()
int
hashCode()
CSSSimpleValueWithUnit
multiply(double dValue)
Get a new object with the same unit but a multiplied value.CSSSimpleValueWithUnit
multiply(BigDecimal aValue)
Get a new object with the same unit but a multiplied value.CSSSimpleValueWithUnit
setUnit(ECSSUnit eUnit)
Set the unit type.CSSSimpleValueWithUnit
setValue(double dValue)
Set the numerical value.CSSSimpleValueWithUnit
setValue(BigDecimal aValue)
Set the numerical value.CSSSimpleValueWithUnit
substract(double dDelta)
Get a new object with the same unit but a subtracted value.CSSSimpleValueWithUnit
substract(BigDecimal aDelta)
Get a new object with the same unit but a subtracted value.String
toString()
-
-
-
Constructor Detail
-
CSSSimpleValueWithUnit
public CSSSimpleValueWithUnit(@Nonnull BigDecimal aValue, @Nonnull ECSSUnit eUnit)
Constructor- Parameters:
aValue
- Numeric value. May not benull
.eUnit
- CSS unit to use. May not benull
.
-
-
Method Detail
-
setValue
@Nonnull public CSSSimpleValueWithUnit setValue(@Nonnull BigDecimal aValue)
Set the numerical value.- Parameters:
aValue
- The new value to set. May not benull
.- Returns:
- this
- Since:
- 3.7.3
-
setValue
@Nonnull public CSSSimpleValueWithUnit setValue(double dValue)
Set the numerical value.- Parameters:
dValue
- The new value to set.- Returns:
- this
- Since:
- 3.7.3
-
getAsBigDecimalValue
@Nonnull public BigDecimal getAsBigDecimalValue()
- Returns:
- The numeric value as a decimal value (as passed in the constructor)
- Since:
- 3.7.3
-
getValue
public double getValue()
- Returns:
- The numeric value as a decimal value (as passed in the constructor)
-
getAsIntValue
public int getAsIntValue()
- Returns:
- The numeric value as an int value - no check for validity is performed
-
getAsLongValue
public long getAsLongValue()
- Returns:
- The numeric value as a long value - no check for validity is performed
-
setUnit
@Nonnull public CSSSimpleValueWithUnit setUnit(@Nonnull ECSSUnit eUnit)
Set the unit type.- Parameters:
eUnit
- The new unit to set. May not benull
.- Returns:
- this
- Since:
- 3.7.3
-
getFormatted
@Nonnull @Nonempty public String getFormatted()
- Returns:
- The formatted string value of this item. Neither
null
nor empty. - Since:
- 3.7.3
-
add
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit add(@Nonnull BigDecimal aDelta)
Get a new object with the same unit but an added value.- Parameters:
aDelta
- The delta to be added. May not benull
.- Returns:
- A new object. Never
null
. - Since:
- 3.7.3
-
add
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit add(double dDelta)
Get a new object with the same unit but an added value.- Parameters:
dDelta
- The delta to be added.- Returns:
- A new object. Never
null
.
-
substract
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit substract(@Nonnull BigDecimal aDelta)
Get a new object with the same unit but a subtracted value.- Parameters:
aDelta
- The delta to be subtracted. May not benull
.- Returns:
- A new object. Never
null
. - Since:
- 3.7.3
-
substract
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit substract(double dDelta)
Get a new object with the same unit but a subtracted value.- Parameters:
dDelta
- The delta to be subtracted.- Returns:
- A new object. Never
null
.
-
multiply
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit multiply(@Nonnull BigDecimal aValue)
Get a new object with the same unit but a multiplied value.- Parameters:
aValue
- The value to be multiply with this value. May not benull
.- Returns:
- A new object. Never
null
. - Since:
- 3.7.3
-
multiply
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit multiply(double dValue)
Get a new object with the same unit but a multiplied value.- Parameters:
dValue
- The value to be multiply with this value.- Returns:
- A new object. Never
null
.
-
divide
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit divide(@Nonnull BigDecimal aDivisor, @Nonnegative int nScale, @Nonnull RoundingMode eRoundingMode)
Get a new object with the same unit but an divided value.- Parameters:
aDivisor
- The divisor to use. May not benull
.nScale
- The maximum fraction digits to use.eRoundingMode
- The rounding mode to use. May not benull
.- Returns:
- A new object. Never
null
. - Since:
- 3.7.3
-
divide
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit divide(@Nonnull BigDecimal aDivisor)
Get a new object with the same unit but an divided value. By defaultCCSS.CSS_MAXIMUM_FRACTION_DIGITS
is used as scale andRoundingMode.HALF_UP
is used as rounding mode.- Parameters:
aDivisor
- The divisor to use. May not benull
.- Returns:
- A new object. Never
null
. - Since:
- 3.7.3
-
divide
@Nonnull @CheckReturnValue public CSSSimpleValueWithUnit divide(double dDivisor)
Get a new object with the same unit but an divided value.- Parameters:
dDivisor
- The divisor to use.- Returns:
- A new object. Never
null
.
-
-