| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import org.forgerock.util.Reject; |
| | |
| | | * The enumeration that should be used for values of this |
| | | * property definition. |
| | | */ |
| | | public static class Builder<E extends Enum<E>> extends AbstractBuilder<E, EnumPropertyDefinition<E>> { |
| | | public final static class Builder<E extends Enum<E>> extends AbstractBuilder<E, EnumPropertyDefinition<E>> { |
| | | |
| | | // The enumeration class. |
| | | private Class<E> enumClass; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<E> defaultBehavior) { |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<E> defaultBehavior) { |
| | | // Make sure that the enumeration class has been defined. |
| | | if (enumClass == null) { |
| | | throw new IllegalStateException("Enumeration class undefined"); |
| | |
| | | * @return Returns the new enumeration property definition builder. |
| | | */ |
| | | public static <E extends Enum<E>> Builder<E> createBuilder(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName) { |
| | | String propertyName) { |
| | | return new Builder<E>(d, propertyName); |
| | | } |
| | | |
| | |
| | | |
| | | // Private constructor. |
| | | private EnumPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<E> defaultBehavior, Class<E> enumClass) { |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<E> defaultBehavior, |
| | | Class<E> enumClass) { |
| | | super(d, enumClass, propertyName, options, adminAction, defaultBehavior); |
| | | this.enumClass = enumClass; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public E decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public E decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String normalizeValue(E value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(E value) { |
| | | Reject.ifNull(value); |
| | | |
| | | return value.toString().trim().toLowerCase(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(E value) throws IllegalPropertyValueException { |
| | | public void validateValue(E value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |