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

matthew_swift
25.27.2006 41b55639b4f1dc436913737400623be050539fff
Refactoring: simplify the AttributeType.isOperational() method, by providing
an "isOperational" getter in the AttributeUsage enumeration.
2 files modified
57 ■■■■■ changed files
opends/src/server/org/opends/server/types/AttributeType.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/AttributeUsage.java 39 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/AttributeType.java
@@ -43,7 +43,6 @@
import org.opends.server.core.DirectoryServer;
import static org.opends.server.loggers.Debug.*;
import static org.opends.server.loggers.Error.*;
import static org.opends.server.messages.CoreMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
@@ -723,22 +722,7 @@
  {
    assert debugEnter(CLASS_NAME, "isOperational");
    switch (attributeUsage)
    {
      case USER_APPLICATIONS:
        return false;
      case DIRECTORY_OPERATION:
      case DISTRIBUTED_OPERATION:
      case DSA_OPERATION:
        return true;
    }
    // We should never get here.  If we do, assume it's a user-defined
    // attribute.
    logError(ErrorLogCategory.CORE_SERVER,
             ErrorLogSeverity.SEVERE_WARNING,
             MSGID_UNKNOWN_ATTRIBUTE_USAGE, getNameOrOID());
    return false;
    return attributeUsage.isOperational();
  }
opends/src/server/org/opends/server/types/AttributeUsage.java
@@ -37,14 +37,14 @@
  /**
   * The attribute usage intended for user-defined attribute types.
   */
  USER_APPLICATIONS("userApplications"),
  USER_APPLICATIONS("userApplications", false),
  /**
   * The attribute usage intended for standard operational attributes.
   */
  DIRECTORY_OPERATION("directoryOperation"),
  DIRECTORY_OPERATION("directoryOperation", true),
@@ -52,7 +52,7 @@
   * The attribute usage intended for non-standard operational
   * attributes shared among multiple DSAs.
   */
  DISTRIBUTED_OPERATION("distributedOperation"),
  DISTRIBUTED_OPERATION("distributedOperation", true),
@@ -60,12 +60,16 @@
   * The attribute usage intended for non-standard operational
   * attributes used by a single DSA.
   */
  DSA_OPERATION("dSAOperation");
  DSA_OPERATION("dSAOperation", true);
  // The string representation of this attribute usage.
  String usageString;
  private final String usageString;
  // Flag indicating whether or not the usage should be categorized as
  // operational.
  private final boolean isOperational;
@@ -73,12 +77,17 @@
   * Creates a new attribute usage with the provided string
   * representation.
   *
   * @param  usageString  The string representation of this attribute
   *                      usage.
   * @param usageString
   *          The string representation of this attribute usage.
   * @param isOperational
   *          <code>true</code> if attributes having this attribute
   *          usage are operational, or <code>false</code>
   *          otherwise.
   */
  private AttributeUsage(String usageString)
  private AttributeUsage(String usageString, boolean isOperational)
  {
    this.usageString = usageString;
    this.isOperational = isOperational;
  }
@@ -92,5 +101,19 @@
  {
    return usageString;
  }
  /**
   * Determine whether or not attributes having this attribute usage
   * are operational.
   *
   * @return Returns <code>true</code> if attributes having this
   *         attribute usage are operational, or <code>false</code>
   *         otherwise.
   */
  public boolean isOperational() {
    return isOperational;
  }
}