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
-
Constructor Summary
ConstructorDescriptionSizeWithUnit
(float size, SizeUnit unit) Constructs a new SizeWithUnit object representing the pair (size, unit). -
Method Summary
Modifier and TypeMethodDescriptionfloat
getSize()
Returns the numeric value stored in this object.getUnit()
Returns the size unit stored in this object.static SizeWithUnit
parseStringSize
(String size) Returns an object whose numeric value and unit are taken from the string size.static SizeWithUnit
parseStringSize
(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
. IfsizeString
does not specify a unit anddefaultUnit
is not null,defaultUnit
is 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 ifsizeString
does not contain any unit. Usenull
for 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
-