Class CustomizableCoordinate
java.lang.Object
net.okapia.osid.primordium.mapping.CustomizableCoordinate
- All Implemented Interfaces:
Serializable, Comparable<Coordinate>, Coordinate, OsidPrimitive, Coordinate, OsidPrimitive
A
Coordinate that wraps another coordinate and forwards every
method to it, so it carries exactly the wrapped value and the same
identity: it is equal to the coordinate it wraps and to any other
coordinate 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 CustomizableCoordinate.Codec to coordinate(org.osid.mapping.Coordinate, 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 coordinate to a string and parses it back. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomizableCoordinate(Coordinate delegate) Constructs a newCustomizableCoordinatethat renders with the wrapped coordinate's own string form.protectedCustomizableCoordinate(Coordinate delegate, CustomizableCoordinate.Codec codec) Constructs a newCustomizableCoordinatethat renders with the given codec. -
Method Summary
Modifier and TypeMethodDescriptionfinal intcompareTo(Coordinate arg0) static CustomizableCoordinatecoordinate(Coordinate coordinate) Wraps a coordinate, rendering with its own string form.static CustomizableCoordinatecoordinate(Coordinate coordinate, CustomizableCoordinate.Codec codec) Wraps a coordinate, rendering with the given codec.final booleanfinal Typeprotected CoordinateGets the wrapped coordinate.final longfinal BigDecimal[]final inthashCode()final booleanisCloser(Coordinate arg0, Coordinate arg1) final booleanisExclusive(Coordinate arg0) final booleanisFarther(Coordinate arg0, Coordinate arg1) final booleanisInclusive(Coordinate arg0) final booleanisLarger(Coordinate arg0) final booleanisSmaller(Coordinate arg0) toString()Returns the string form of this coordinate.static CustomizableCoordinatevalueOf(Coordinate coordinate) Wraps a coordinate, rendering with its own string form.static CustomizableCoordinatevalueOf(Coordinate coordinate, CustomizableCoordinate.Codec codec) Wraps a coordinate, rendering with the given codec.
-
Constructor Details
-
CustomizableCoordinate
Constructs a newCustomizableCoordinatethat renders with the wrapped coordinate's own string form.- Parameters:
delegate- the coordinate to wrap- Throws:
NullArgumentException-delegateisnull
-
CustomizableCoordinate
Constructs a newCustomizableCoordinatethat renders with the given codec.- Parameters:
delegate- the coordinate to wrapcodec- the codec used bytoString(), ornullto render with the wrapped coordinate's own string form- Throws:
NullArgumentException-delegateisnull
-
-
Method Details
-
valueOf
Wraps a coordinate, rendering with its own string form.- Parameters:
coordinate- the coordinate to wrap- Returns:
- the wrapped coordinate
- Throws:
NullArgumentException-coordinateisnull- See Also:
-
coordinate
Wraps a coordinate, rendering with its own string form.- Parameters:
coordinate- the coordinate to wrap- Returns:
- the wrapped coordinate
- Throws:
NullArgumentException-coordinateisnull- See Also:
-
valueOf
public static CustomizableCoordinate valueOf(Coordinate coordinate, CustomizableCoordinate.Codec codec) Wraps a coordinate, rendering with the given codec.- Parameters:
coordinate- the coordinate to wrapcodec- the codec used bytoString()- Returns:
- the wrapped coordinate
- Throws:
NullArgumentException-coordinateorcodecisnull- See Also:
-
coordinate
public static CustomizableCoordinate coordinate(Coordinate coordinate, CustomizableCoordinate.Codec codec) Wraps a coordinate, rendering with the given codec.- Parameters:
coordinate- the coordinate to wrapcodec- the codec used bytoString()- Returns:
- the wrapped coordinate
- Throws:
NullArgumentException-coordinateorcodecisnull- See Also:
-
getDelegate
-
getCoordinateType
- Specified by:
getCoordinateTypein interfaceCoordinate
-
getDimensions
- Specified by:
getDimensionsin interfaceCoordinate
-
getValues
- Specified by:
getValuesin interfaceCoordinate
-
isLarger
- Specified by:
isLargerin interfaceCoordinate
-
isSmaller
- Specified by:
isSmallerin interfaceCoordinate
-
isCloser
- Specified by:
isCloserin interfaceCoordinate
-
isFarther
- Specified by:
isFartherin interfaceCoordinate
-
isInclusive
- Specified by:
isInclusivein interfaceCoordinate
-
isExclusive
- Specified by:
isExclusivein interfaceCoordinate
-
compareTo
- Specified by:
compareToin interfaceComparable<Coordinate>- Specified by:
compareToin interfaceCoordinate
-
equals
- Specified by:
equalsin interfaceCoordinate- Overrides:
equalsin classObject
-
hashCode
- Specified by:
hashCodein interfaceCoordinate- Overrides:
hashCodein classObject
-
toString
Returns the string form of this coordinate. With a codec, this iscodec.format(wrapped); otherwise it is the wrapped coordinate's own string form. This is the one method a subclass may override.- Specified by:
toStringin interfaceOsidPrimitive- Overrides:
toStringin classObject- Returns:
- the string form
-