| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | * maximum unit. |
| | | */ |
| | | public final void setBaseUnit(String unit) throws IllegalArgumentException { |
| | | ensureNotNull(unit); |
| | | Reject.ifNull(unit); |
| | | |
| | | setBaseUnit(DurationUnit.getUnit(unit)); |
| | | } |
| | |
| | | * unit. |
| | | */ |
| | | public final void setBaseUnit(DurationUnit unit) throws IllegalArgumentException { |
| | | ensureNotNull(unit); |
| | | Reject.ifNull(unit); |
| | | |
| | | // Make sure that the base unit is not bigger than the maximum |
| | | // unit. |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | long nvalue = baseUnit.toMilliSeconds(value); |
| | | if (!allowUnlimited && nvalue < lowerLimit) { |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as |
| | | // "unlimited". |
| | |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | | if (allowUnlimited) { |