Package com.helger.css.propertyvalue
Class CSSSimpleValueWithUnit
java.lang.Object
com.helger.css.propertyvalue.CSSSimpleValueWithUnit
This class encapsulates a single numeric value and a unit (
ECSSUnit).- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionCSSSimpleValueWithUnit(double dValue, ECSSUnit eUnit) ConstructorCSSSimpleValueWithUnit(BigDecimal aValue, ECSSUnit eUnit) Constructor -
Method Summary
Modifier and TypeMethodDescriptionadd(double dDelta) Get a new object with the same unit but an added value.add(BigDecimal aDelta) Get a new object with the same unit but an added value.divide(double dDivisor) Get a new object with the same unit but an divided value.divide(BigDecimal aDivisor) Get a new object with the same unit but an divided value.divide(BigDecimal aDivisor, int nScale, RoundingMode eRoundingMode) Get a new object with the same unit but an divided value.booleanintlonggetUnit()doublegetValue()inthashCode()multiply(double dValue) Get a new object with the same unit but a multiplied value.multiply(BigDecimal aValue) Get a new object with the same unit but a multiplied value.Set the unit type.setValue(double dValue) Set the numerical value.setValue(BigDecimal aValue) Set the numerical value.substract(double dDelta) Get a new object with the same unit but a subtracted value.substract(BigDecimal aDelta) Get a new object with the same unit but a subtracted value.toString()
-
Constructor Details
-
CSSSimpleValueWithUnit
Constructor- Parameters:
aValue- Numeric value. May not benull.eUnit- CSS unit to use. May not benull.
-
CSSSimpleValueWithUnit
Constructor- Parameters:
dValue- Numeric valueeUnit- CSS unit to use. May not benull.
-
-
Method Details
-
setValue
Set the numerical value.- Parameters:
aValue- The new value to set. May not benull.- Returns:
- this
- Since:
- 3.7.3
-
setValue
Set the numerical value.- Parameters:
dValue- The new value to set.- Returns:
- this
- Since:
- 3.7.3
-
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
Set the unit type.- Parameters:
eUnit- The new unit to set. May not benull.- Returns:
- this
- Since:
- 3.7.3
-
getUnit
- Returns:
- The CSS unit of this value. Never
null.
-
getFormatted
- Returns:
- The formatted string value of this item. Neither
nullnor empty. - Since:
- 3.7.3
-
add
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
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
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
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
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
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
Get a new object with the same unit but an divided value. By defaultCCSS.CSS_MAXIMUM_FRACTION_DIGITSis used as scale andRoundingMode.HALF_UPis used as rounding mode.- Parameters:
aDivisor- The divisor to use. May not benull.- Returns:
- A new object. Never
null. - Since:
- 3.7.3
-
divide
Get a new object with the same unit but an divided value.- Parameters:
dDivisor- The divisor to use.- Returns:
- A new object. Never
null.
-
equals
-
hashCode
public int hashCode() -
toString
-