org.joda.time.field

Class DecoratedDurationField

Implemented Interfaces:
Comparable, Serializable
Known Direct Subclasses:
ScaledDurationField

public class DecoratedDurationField
extends BaseDurationField

DecoratedDurationField extends BaseDurationField, implementing only the minimum required set of methods. These implemented methods delegate to a wrapped field.

This design allows new DurationField types to be defined that piggyback on top of another, inheriting all the safe method implementations from BaseDurationField. Should any method require pure delegation to the wrapped field, simply override and use the provided getWrappedField method.

DecoratedDurationField is thread-safe and immutable, and its subclasses must be as well.

Author:
Brian S O'Neill
Since:
1.0
See Also:
DelegatedDurationField

Constructor Summary

DecoratedDurationField(DurationField field, DurationFieldType type)
Constructor.

Method Summary

long
add(long instant, int value)
long
add(long instant, long value)
long
getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
long
getMillis(int value, long instant)
long
getMillis(long value, long instant)
long
getUnitMillis()
long
getValueAsLong(long duration, long instant)
DurationField
getWrappedField()
Gets the wrapped duration field.
boolean
isPrecise()

Methods inherited from class org.joda.time.field.BaseDurationField

compareTo, getDifference, getMillis, getMillis, getName, getType, getValue, getValue, getValueAsLong, isSupported, toString

Methods inherited from class org.joda.time.DurationField

add, add, compareTo, getDifference, getDifferenceAsLong, getMillis, getMillis, getMillis, getMillis, getName, getType, getUnitMillis, getValue, getValue, getValueAsLong, getValueAsLong, isPrecise, isSupported, subtract, subtract, toString

Constructor Details

DecoratedDurationField

public DecoratedDurationField(DurationField field,
                              DurationFieldType type)
Constructor.
Parameters:
field - the base field
type - the type to actually use

Method Details

add

public long add(long instant,
                int value)
Overrides:
add in interface DurationField

add

public long add(long instant,
                long value)
Overrides:
add in interface DurationField

getDifferenceAsLong

public long getDifferenceAsLong(long minuendInstant,
                                long subtrahendInstant)
Overrides:
getDifferenceAsLong in interface DurationField

getMillis

public long getMillis(int value,
                      long instant)
Overrides:
getMillis in interface DurationField

getMillis

public long getMillis(long value,
                      long instant)
Overrides:
getMillis in interface DurationField

getUnitMillis

public long getUnitMillis()
Overrides:
getUnitMillis in interface DurationField

getValueAsLong

public long getValueAsLong(long duration,
                           long instant)
Overrides:
getValueAsLong in interface DurationField

getWrappedField

public final DurationField getWrappedField()
Gets the wrapped duration field.
Returns:
the wrapped DurationField

isPrecise

public boolean isPrecise()
Overrides:
isPrecise in interface DurationField

Copyright (c) 2001-2006 - Joda.org