Class CustomizableSpeed
java.lang.Object
net.okapia.osid.primordium.mapping.CustomizableSpeed
- All Implemented Interfaces:
Serializable, Comparable<Speed>, OsidPrimitive, Speed, Speed, OsidPrimitive
A
Speed that wraps another speed and forwards every
method to it, so it carries exactly the wrapped value and the same
identity: it is equal to the speed it wraps and to any other
speed of the same value. The single seam is toString();
every other method is final, so a subclass cannot reach
anything the contract depends on. Customize the string form by
passing a CustomizableSpeed.Codec to speed(org.osid.mapping.Speed, Codec), or by subclassing and overriding toString().
See CustomizableDistance
for the full design rationale (value-based identity, the
toString() seam, and the bundling pattern). Intentionally not
final.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFormats a speed to a string and parses it back. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomizableSpeed(Speed delegate) Constructs a newCustomizableSpeedthat renders with the wrapped speed's own string form.protectedCustomizableSpeed(Speed delegate, CustomizableSpeed.Codec codec) Constructs a newCustomizableSpeedthat renders with the given codec. -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal booleanprotected SpeedGets the wrapped speed.final Distancefinal Speedfinal DateTimeResolutionfinal Speedfinal inthashCode()final booleanisContained(Speed arg0, Speed arg1) final booleanisExclusive(Speed arg0) final booleanisExclusive(Speed arg0, Speed arg1) final booleanfinal booleanisInclusive(Speed arg0) final booleanstatic CustomizableSpeedWraps a speed, rendering with its own string form.static CustomizableSpeedspeed(Speed speed, CustomizableSpeed.Codec codec) Wraps a speed, rendering with the given codec.toString()Returns the string form of this speed.
-
Constructor Details
-
CustomizableSpeed
Constructs a newCustomizableSpeedthat renders with the wrapped speed's own string form.- Parameters:
delegate- the speed to wrap- Throws:
NullArgumentException-delegateisnull
-
CustomizableSpeed
Constructs a newCustomizableSpeedthat renders with the given codec.- Parameters:
delegate- the speed to wrapcodec- the codec used bytoString(), ornullto render with the wrapped speed's own string form- Throws:
NullArgumentException-delegateisnull
-
-
Method Details
-
speed
Wraps a speed, rendering with its own string form.- Parameters:
speed- the speed to wrap- Returns:
- the wrapped speed
- Throws:
NullArgumentException-speedisnull
-
speed
Wraps a speed, rendering with the given codec.- Parameters:
speed- the speed to wrapcodec- the codec used bytoString()- Returns:
- the wrapped speed
- Throws:
NullArgumentException-speedorcodecisnull
-
getDelegate
-
getDistance
- Specified by:
getDistancein interfaceSpeed
-
getTimeUnit
- Specified by:
getTimeUnitin interfaceSpeed
-
isGreater
-
isLess
-
isInclusive
- Specified by:
isInclusivein interfaceSpeed
-
isContained
- Specified by:
isContainedin interfaceSpeed
-
isExclusive
- Specified by:
isExclusivein interfaceSpeed
-
isExclusive
- Specified by:
isExclusivein interfaceSpeed
-
getLowerBound
- Specified by:
getLowerBoundin interfaceSpeed
-
getUpperBound
- Specified by:
getUpperBoundin interfaceSpeed
-
compareTo
- Specified by:
compareToin interfaceComparable<Speed>- Specified by:
compareToin interfaceSpeed
-
equals
-
hashCode
-
toString
Returns the string form of this speed. With a codec, this iscodec.format(wrapped); otherwise it is the wrapped speed's own string form. This is the one method a subclass may override.- Specified by:
toStringin interfaceOsidPrimitive- Overrides:
toStringin classObject- Returns:
- the string form
-