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

Nicolas Capponi
02.21.2013 e8388c3f6461f17415b6578d2dad0b4d13138282
OpenDJ 3 : config framework

Reducing compilation errors in org.opends.server.admin packages :
all classes in package org.opends.server.admin.condition compile

* Simple changes in org.opends.server.admin.condition package
** use Validator class from SDK
** remove API annotation
6 files modified
195 ■■■■ changed files
opendj-admin/src/main/java/org/opends/server/admin/condition/ANDCondition.java 32 ●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java 72 ●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/IsPresentCondition.java 26 ●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/NOTCondition.java 31 ●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/ORCondition.java 32 ●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/package-info.java 2 ●●●●● patch | view | raw | blame | history
opendj-admin/src/main/java/org/opends/server/admin/condition/ANDCondition.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.admin.condition;
import java.util.Arrays;
import java.util.List;
@@ -38,41 +36,33 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.config.ConfigException;
import org.opends.server.util.Validator;
import com.forgerock.opendj.util.Validator;
/**
 * A condition which evaluates to <code>true</code> if and only if
 * all of its sub-conditions are <code>true</code>.
 * A condition which evaluates to <code>true</code> if and only if all of its
 * sub-conditions are <code>true</code>.
 */
public final class ANDCondition implements Condition {
  // The list of sub-conditions.
  private final List<Condition> conditions;
  /**
   * Creates a new logical AND condition with the provided
   * sub-conditions.
     * Creates a new logical AND condition with the provided sub-conditions.
   *
   * @param conditions
   *          The sub-conditions which will be combined using a
   *          logical AND.
     *            The sub-conditions which will be combined using a logical AND.
   */
  public ANDCondition(Condition... conditions) {
    Validator.ensureNotNull(conditions);
    this.conditions = Arrays.asList(conditions);
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    for (Condition condition : conditions) {
      if (!condition.evaluate(context, managedObject)) {
@@ -82,13 +72,10 @@
    return true;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
    for (Condition condition : conditions) {
      if (!condition.evaluate(managedObject)) {
        return false;
@@ -97,13 +84,10 @@
    return true;
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
    for (Condition condition : conditions) {
      condition.initialize(d);
    }
opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.admin.condition;
import java.util.SortedSet;
import org.opends.server.admin.AbstractManagedObjectDefinition;
@@ -39,13 +37,12 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.config.ConfigException;
import org.opends.server.util.Validator;
import com.forgerock.opendj.util.Validator;
/**
 * A condition which evaluates to <code>true</code> if and only if a
 * property contains a particular value.
 * A condition which evaluates to <code>true</code> if and only if a property
 * contains a particular value.
 */
public final class ContainsCondition implements Condition {
@@ -63,50 +60,36 @@
    // The required property value.
    final T value;
    // Private constructor.
    private Impl(PropertyDefinition<T> pd, T value)
        throws IllegalPropertyValueStringException {
        private Impl(PropertyDefinition<T> pd, T value) throws IllegalPropertyValueStringException {
      this.pd = pd;
      this.value = value;
    }
    /**
     * {@inheritDoc}
     */
    public boolean evaluate(ManagementContext context,
        ManagedObject<?> managedObject) throws AuthorizationException,
        CommunicationException {
        public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject)
                throws AuthorizationException, CommunicationException {
      SortedSet<T> values = managedObject.getPropertyValues(pd);
      return values.contains(value);
    }
    /**
     * {@inheritDoc}
     */
    public boolean evaluate(ServerManagedObject<?> managedObject)
        throws ConfigException {
        public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
      SortedSet<T> values = managedObject.getPropertyValues(pd);
      return values.contains(value);
    }
    /**
     * {@inheritDoc}
     */
    public void initialize(AbstractManagedObjectDefinition<?, ?> d)
        throws Exception {
        public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
      // Not used.
    }
    // Private implementation of fix() method.
    private void setPropertyValue(ManagedObject<?> managedObject) {
      managedObject.setPropertyValue(pd, value);
@@ -123,16 +106,13 @@
  // The string representation of the required property value.
  private final String propertyStringValue;
  /**
   * Creates a new contains value condition.
   *
   * @param propertyName
   *          The property name.
   * @param stringValue
   *          The string representation of the required property
   *          value.
     *            The string representation of the required property value.
   */
  public ContainsCondition(String propertyName, String stringValue) {
    Validator.ensureNotNull(propertyName, stringValue);
@@ -140,32 +120,24 @@
    this.propertyStringValue = stringValue;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    return impl.evaluate(context, managedObject);
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
    return impl.evaluate(managedObject);
  }
  /**
   * Modifies the provided managed object so that it has the property
   * value associated with this condition.
     * Modifies the provided managed object so that it has the property value
     * associated with this condition.
   *
   * @param managedObject
   *          The managed object.
@@ -174,41 +146,35 @@
    impl.setPropertyValue(managedObject);
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
    // Decode the property.
    buildImpl(d.getPropertyDefinition(propertyName));
  }
  // Creates the new private implementation.
  private <T> void buildImpl(PropertyDefinition<T> pd)
      throws IllegalPropertyValueStringException {
    private <T> void buildImpl(PropertyDefinition<T> pd) throws IllegalPropertyValueStringException {
    T value = pd.decodeValue(propertyStringValue);
    this.impl = new Impl<T>(pd, value);
  }
  /**
   * Returns the property definition associated with this condition.
     *
   * @return the property definition associated with this condition.
   */
  public PropertyDefinition<?> getPropertyDefinition()
  {
    public PropertyDefinition<?> getPropertyDefinition() {
    return impl.pd;
  }
  /**
   * Returns the value that must be set for this condition to be fulfilled.
     *
   * @return the value that must be set for this condition to be fulfilled.
   */
  public Object getValue()
  {
    public Object getValue() {
    return impl.value;
  }
}
opendj-admin/src/main/java/org/opends/server/admin/condition/IsPresentCondition.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.admin.condition;
import java.util.SortedSet;
import org.opends.server.admin.AbstractManagedObjectDefinition;
@@ -38,13 +36,12 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.config.ConfigException;
import org.opends.server.util.Validator;
import com.forgerock.opendj.util.Validator;
/**
 * A condition which evaluates to <code>true</code> if and only if a
 * particular property has any values specified.
 * A condition which evaluates to <code>true</code> if and only if a particular
 * property has any values specified.
 */
public final class IsPresentCondition implements Condition {
@@ -54,8 +51,6 @@
  // The property definition.
  private PropertyDefinition<?> pd;
  /**
   * Creates a new is present condition.
   *
@@ -67,36 +62,27 @@
    this.propertyName = propertyName;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    SortedSet<?> values = managedObject.getPropertyValues(pd);
    return !values.isEmpty();
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
    SortedSet<?> values = managedObject.getPropertyValues(pd);
    return !values.isEmpty();
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
    // Decode the property.
    this.pd = d.getPropertyDefinition(propertyName);
  }
opendj-admin/src/main/java/org/opends/server/admin/condition/NOTCondition.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.admin.condition;
import org.opends.server.admin.AbstractManagedObjectDefinition;
import org.opends.server.admin.client.AuthorizationException;
import org.opends.server.admin.client.CommunicationException;
@@ -35,25 +33,21 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.config.ConfigException;
import org.opends.server.util.Validator;
import com.forgerock.opendj.util.Validator;
/**
 * A condition which evaluates to <code>true</code> if the
 * sub-condition is <code>false</code>, or <code>false</code> if
 * the sub-condition is <code>true</code>.
 * A condition which evaluates to <code>true</code> if the sub-condition is
 * <code>false</code>, or <code>false</code> if the sub-condition is
 * <code>true</code>.
 */
public final class NOTCondition implements Condition {
  // The single sub-condition.
  private final Condition condition;
  /**
   * Creates a new logical NOT condition with the provided
   * sub-condition.
     * Creates a new logical NOT condition with the provided sub-condition.
   *
   * @param condition
   *          The sub-condition which will be inverted.
@@ -63,34 +57,25 @@
    this.condition = condition;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    return !condition.evaluate(context, managedObject);
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
    return !condition.evaluate(managedObject);
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
    condition.initialize(d);
  }
opendj-admin/src/main/java/org/opends/server/admin/condition/ORCondition.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.admin.condition;
import java.util.Arrays;
import java.util.List;
@@ -38,41 +36,33 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.config.ConfigException;
import org.opends.server.util.Validator;
import com.forgerock.opendj.util.Validator;
/**
 * A condition which evaluates to <code>false</code> if and only if
 * all of its sub-conditions are <code>false</code>.
 * A condition which evaluates to <code>false</code> if and only if all of its
 * sub-conditions are <code>false</code>.
 */
public final class ORCondition implements Condition {
  // The list of sub-conditions.
  private final List<Condition> conditions;
  /**
   * Creates a new logical OR condition with the provided
   * sub-conditions.
     * Creates a new logical OR condition with the provided sub-conditions.
   *
   * @param conditions
   *          The sub-conditions which will be combined using a
   *          logical OR.
     *            The sub-conditions which will be combined using a logical OR.
   */
  public ORCondition(Condition... conditions) {
    Validator.ensureNotNull(conditions);
    this.conditions = Arrays.asList(conditions);
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    for (Condition condition : conditions) {
      if (condition.evaluate(context, managedObject)) {
@@ -82,13 +72,10 @@
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
    for (Condition condition : conditions) {
      if (condition.evaluate(managedObject)) {
        return true;
@@ -97,13 +84,10 @@
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
    for (Condition condition : conditions) {
      condition.initialize(d);
    }
opendj-admin/src/main/java/org/opends/server/admin/condition/package-info.java
@@ -31,6 +31,4 @@
 * This package contains interfaces for building and evaluating
 * arbitrary logical conditions which can be used with constraints.
 */
@org.opends.server.types.PublicAPI(
    stability = org.opends.server.types.StabilityLevel.PRIVATE)
package org.opends.server.admin.condition;