UnitBuilder

class UnitBuilder<U : Unit<U>?>

Builder used for easily deriving new units from existing ones. When deriving a new unit, the base unit class must redeclare the constructor (U, UnaryFunction, UnaryFunction, String, String). The unit builder class will invoke this constructor automatically and build the new unit. Alternatively, new units can be derived by passing an explicit constructor function to make.

Since

1.0.0-pre

Parameters

<U>

the type of the unit

Constructors

Link copied to clipboard
constructor(base: U)
Creates a new unit builder object, building off of a base unit.

Types

Link copied to clipboard
open inner class MappingBuilder
Helper class used for safely chaining mapping builder calls.
Link copied to clipboard
A functional interface for constructing new units without relying on reflection.

Functions

Link copied to clipboard
open fun aggregate(aggregation: Double): UnitBuilder<U>
Helper for defining units that are a scalar multiple of the base unit, such as kilometers being 1000x of the base unit (meters).
Link copied to clipboard
Sets the conversion function to transform values in the base unit to values in the derived unit.
Link copied to clipboard
open fun make(): U
Creates the new unit based off of the builder methods called prior.
Creates the new unit based off of the builder methods called prior, passing them to a provided constructor function.
Link copied to clipboard
Defines a mapping for values within the given input range.
Link copied to clipboard
open fun named(@NonNull name: String): UnitBuilder<U>
Sets the name of the new unit.
Link copied to clipboard
open fun offset(offset: Double): UnitBuilder<U>
Sets the unit conversions based on a simple offset.
Link copied to clipboard
open fun splitInto(fraction: Double): UnitBuilder<U>
Helper for defining units that are a scalar fraction of the base unit, such as centimeters being 1/100th of the base unit (meters).
Link copied to clipboard
open fun symbol(@NonNull symbol: String): UnitBuilder<U>
Sets the symbol of the new unit.
Link copied to clipboard
Sets the conversion function to transform values in the derived unit to values in the base unit.