Class Quantities
java.lang.Object
org.episteme.core.measure.Quantities
Factory for creating
Quantity instances.
Provides convenient factory methods for creating physical quantities.
Example Usage:
import static org.episteme.core.measure.Units.*;
// Create quantities
Quantity<Length> distance = Quantities.create(100, METER);
Quantity<Time> time = Quantities.create(10, SECOND);
// Perform calculations
Quantity<Velocity> speed = distance.divide(time); // 10 m/s
// Convert units
Quantity<Velocity> kmh = speed.to(KILOMETER_PER_HOUR); // 36 km/h
* @author Silvere Martin-Michiellot- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionCreates a quantity from a double value and unit.Creates a quantity from an int value and unit.Creates a quantity from a long value and unit.Creates a quantity from a Real value and unit.static Quantity<?> Parses a quantity from a string representation without specifying unit type.Parses a quantity from a string representation.
-
Method Details
-
create
-
create
-
create
-
create
-
parse
Parses a quantity from a string representation.Expected format: "value unit" (e.g., "100 m", "10.5 kg", "50 km/h")
- Type Parameters:
Q- the quantity type- Parameters:
text- the string to parseexpectedUnit- the expected unit (for validation)- Returns:
- the parsed quantity
- Throws:
IllegalArgumentException- if parsing fails
-
parse
Parses a quantity from a string representation without specifying unit type.Expected format: "value unit" (e.g., "100 m", "10.5 kg", "50 km/h")
This overload returns Quantityinvalid input: '<'?> since the unit type is not known at compile time.
- Parameters:
text- the string to parse- Returns:
- the parsed quantity with unknown type
- Throws:
IllegalArgumentException- if parsing fails
-