Package io.jmix.ui.component
Class SizeWithUnit
java.lang.Object
io.jmix.ui.component.SizeWithUnit
- All Implemented Interfaces:
Serializable
A class for representing a value-unit pair. Also contains utility methods for
parsing such pairs from a string.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSizeWithUnit(float size, SizeUnit unit) Constructs a new SizeWithUnit object representing the pair (size, unit). -
Method Summary
Modifier and TypeMethodDescriptionfloatgetSize()Returns the numeric value stored in this object.getUnit()Returns the size unit stored in this object.static SizeWithUnitparseStringSize(String size) Returns an object whose numeric value and unit are taken from the string size.static SizeWithUnitparseStringSize(String sizeString, SizeUnit defaultUnit) Returns an object whose numeric value and unit are taken from the stringsizeString.
-
Field Details
-
SIZE_PATTERN_STRING
- See Also:
-
SIZE_PATTERN
-
size
protected float size -
unit
-
-
Constructor Details
-
SizeWithUnit
Constructs a new SizeWithUnit object representing the pair (size, unit).- Parameters:
size- a numeric valueunit- a unit
-
-
Method Details
-
getSize
public float getSize()Returns the numeric value stored in this object.- Returns:
- the numeric value stored in this object
-
getUnit
Returns the size unit stored in this object.- Returns:
- the size unit stored in this object
-
stringValue
-
parseStringSize
public static SizeWithUnit parseStringSize(@Nullable String sizeString, @Nullable SizeUnit defaultUnit) Returns an object whose numeric value and unit are taken from the stringsizeString. IfsizeStringdoes not specify a unit anddefaultUnitis not null,defaultUnitis used as the unit. Null, empty or 'AUTO' string will produce {-1, SizeUnit#PIXELS}.- Parameters:
sizeString- the string to be parseddefaultUnit- The unit to be used ifsizeStringdoes not contain any unit. Usenullfor no default unit.- Returns:
- an object containing the parsed value and unit
-
parseStringSize
Returns an object whose numeric value and unit are taken from the string size. Null, empty or 'AUTO' string will produce {-1, SizeUnit#PIXELS}.- Parameters:
size- the string to be parsed- Returns:
- an object containing the parsed value and unit
-