mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
19.48.2007 369b773b44c479a87f71548b03ff264c65477d73
opendj-sdk/opends/src/server/org/opends/server/admin/AbstractPropertyDefinition.java
@@ -32,6 +32,8 @@
import static org.opends.server.util.Validator.ensureNotNull;
import java.util.EnumSet;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.Set;
@@ -56,6 +58,9 @@
  protected abstract static class AbstractBuilder<T,
      D extends PropertyDefinition<T>> {
    //  The abstract managed object
    private final AbstractManagedObjectDefinition<?, ?> definition;
    // The name of this property definition.
    private final String propertyName;
@@ -70,10 +75,15 @@
    /**
     * Create a property definition builder.
     *
     * @param d
     *          The managed object definition associated with this
     *          property definition.
     * @param propertyName
     *          The property name.
     */
    protected AbstractBuilder(String propertyName) {
    protected AbstractBuilder(
        AbstractManagedObjectDefinition<?, ?> d, String propertyName) {
      this.definition = d;
      this.propertyName = propertyName;
      this.options = EnumSet.noneOf(PropertyOption.class);
      this.defaultBehavior = new UndefinedDefaultBehaviorProvider<T>();
@@ -87,7 +97,7 @@
     * @return The new property definition.
     */
    public final D getInstance() {
      return buildInstance(propertyName, options, defaultBehavior);
      return buildInstance(definition, propertyName, options, defaultBehavior);
    }
@@ -120,8 +130,12 @@
    /**
     * Build a property definition based on the properties of this builder.
     * Build a property definition based on the properties of this
     * builder.
     *
     * @param d
     *          The managed object definition associated with this
     *          property definition.
     * @param propertyName
     *          The property name.
     * @param options
@@ -130,7 +144,8 @@
     *          The default behavior provider.
     * @return The new property definition.
     */
    protected abstract D buildInstance(String propertyName,
    protected abstract D buildInstance(
        AbstractManagedObjectDefinition<?, ?> d, String propertyName,
        EnumSet<PropertyOption> options,
        DefaultBehaviorProvider<T> defaultBehavior);
  }
@@ -147,11 +162,17 @@
  // The default behavior provider.
  private final DefaultBehaviorProvider<T> defaultBehavior;
  // The abstract managed object
  private final AbstractManagedObjectDefinition<?, ?> definition;
  /**
   * Create a property definition.
   *
   * @param d
   *          The managed object definition associated with this
   *          property definition.
   * @param theClass
   *          The property value class.
   * @param propertyName
@@ -161,11 +182,14 @@
   * @param defaultBehavior
   *          The default behavior provider.
   */
  protected AbstractPropertyDefinition(Class<T> theClass, String propertyName,
  protected AbstractPropertyDefinition(AbstractManagedObjectDefinition<?,?> d,
      Class<T> theClass, String propertyName,
      EnumSet<PropertyOption> options,
      DefaultBehaviorProvider<T> defaultBehavior) {
    ensureNotNull(theClass, propertyName, options, defaultBehavior);
    ensureNotNull(d, theClass, propertyName);
    ensureNotNull(options, defaultBehavior);
    this.definition = d;
    this.theClass = theClass;
    this.propertyName = propertyName;
    this.options = EnumSet.copyOf(options);
@@ -280,6 +304,45 @@
  /**
   * {@inheritDoc}
   */
  public final String getDescription() {
    return getDescription(Locale.getDefault());
  }
  /**
   * {@inheritDoc}
   */
  public final String getDescription(Locale locale) {
    ManagedObjectDefinitionI18NResource resource =
      ManagedObjectDefinitionI18NResource.getInstance();
    String property = "property." + propertyName + ".description";
    try {
      return resource.getMessage(definition, property, locale);
    } catch (MissingResourceException e) {
      return null;
    }
  }
  /**
   * Gets the managed object definition associated with this property
   * definition.
   *
   * @return Returns the managed object definition associated with
   *         this property definition.
   */
  public final AbstractManagedObjectDefinition<?, ?>
      getManagedObjectDefinition() {
    return definition;
  }
  /**
   * {@inheritDoc}
   */
  public final String getName() {
    return propertyName;
  }
@@ -289,6 +352,31 @@
  /**
   * {@inheritDoc}
   */
  public final String getSynopsis() {
    return getSynopsis(Locale.getDefault());
  }
  /**
   * {@inheritDoc}
   */
  public final String getSynopsis(Locale locale) {
    ManagedObjectDefinitionI18NResource resource =
      ManagedObjectDefinitionI18NResource.getInstance();
    String property = "property." + propertyName + ".synopsis";
    try {
      return resource.getMessage(definition, property, locale);
    } catch (MissingResourceException e) {
      return null;
    }
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public int hashCode() {
    // TODO: see comment in equals().