| | |
| | | */ |
| | | public final class DurationPropertyDefinition extends PropertyDefinition<Long> { |
| | | |
| | | // String used to represent unlimited durations. |
| | | /** String used to represent unlimited durations. */ |
| | | private static final String UNLIMITED = "unlimited"; |
| | | |
| | | // The base unit for this property definition. |
| | | /** The base unit for this property definition. */ |
| | | private final DurationUnit baseUnit; |
| | | |
| | | // The optional maximum unit for this property definition. |
| | | /** The optional maximum unit for this property definition. */ |
| | | private final DurationUnit maximumUnit; |
| | | |
| | | // The lower limit of the property value in milli-seconds. |
| | | /** The lower limit of the property value in milli-seconds. */ |
| | | private final long lowerLimit; |
| | | |
| | | // The optional upper limit of the property value in milli-seconds. |
| | | /** The optional upper limit of the property value in milli-seconds. */ |
| | | private final Long upperLimit; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" |
| | | // duration value (represented using a -1L or the string |
| | | // "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" |
| | | * duration value (represented using a -1L or the string |
| | | * "unlimited"). |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | |
| | |
| | | public static class Builder extends |
| | | AbstractBuilder<Long, DurationPropertyDefinition> { |
| | | |
| | | // The base unit for this property definition. |
| | | /** The base unit for this property definition. */ |
| | | private DurationUnit baseUnit = DurationUnit.SECONDS; |
| | | |
| | | // The optional maximum unit for this property definition. |
| | | /** The optional maximum unit for this property definition. */ |
| | | private DurationUnit maximumUnit; |
| | | |
| | | // The lower limit of the property value in milli-seconds. |
| | | /** The lower limit of the property value in milli-seconds. */ |
| | | private long lowerLimit; |
| | | |
| | | // The optional upper limit of the property value in |
| | | // milli-seconds. |
| | | /** |
| | | * The optional upper limit of the property value in |
| | | * milli-seconds. |
| | | */ |
| | | private Long upperLimit; |
| | | |
| | | // Indicates whether this property allows the use of the |
| | | // "unlimited" duration value (represented using a -1L or the |
| | | // string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the |
| | | * "unlimited" duration value (represented using a -1L or the |
| | | * string "unlimited"). |
| | | */ |
| | | private boolean allowUnlimited; |
| | | |
| | | |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName) { |
| | | super(d, propertyName); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DurationPropertyDefinition buildInstance( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DurationPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, |
| | | AdministratorAction adminAction, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long decodeValue(String value) |
| | | throws PropertyException { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitDuration(this, p); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Long value, P p) { |
| | | return v.visitDuration(this, value, p); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Long o1, Long o2) { |
| | | return o1.compareTo(o2); |