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

Nicolas Capponi
02.21.2013 e8388c3f6461f17415b6578d2dad0b4d13138282
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,75 +36,61 @@
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;
    // The list of sub-conditions.
    private final List<Condition> 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.
   */
  public ORCondition(Condition... conditions) {
    Validator.ensureNotNull(conditions);
    this.conditions = Arrays.asList(conditions);
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ManagementContext context,
      ManagedObject<?> managedObject) throws AuthorizationException,
      CommunicationException {
    for (Condition condition : conditions) {
      if (condition.evaluate(context, managedObject)) {
        return true;
      }
    /**
     * Creates a new logical OR condition with the provided sub-conditions.
     *
     * @param conditions
     *            The sub-conditions which will be combined using a logical OR.
     */
    public ORCondition(Condition... conditions) {
        Validator.ensureNotNull(conditions);
        this.conditions = Arrays.asList(conditions);
    }
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public boolean evaluate(ServerManagedObject<?> managedObject)
      throws ConfigException {
    for (Condition condition : conditions) {
      if (condition.evaluate(managedObject)) {
        return true;
      }
    /**
     * {@inheritDoc}
     */
    public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws AuthorizationException,
            CommunicationException {
        for (Condition condition : conditions) {
            if (condition.evaluate(context, managedObject)) {
                return true;
            }
        }
        return false;
    }
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public void initialize(AbstractManagedObjectDefinition<?, ?> d)
      throws Exception {
    for (Condition condition : conditions) {
      condition.initialize(d);
    /**
     * {@inheritDoc}
     */
    public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException {
        for (Condition condition : conditions) {
            if (condition.evaluate(managedObject)) {
                return true;
            }
        }
        return false;
    }
  }
    /**
     * {@inheritDoc}
     */
    public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception {
        for (Condition condition : conditions) {
            condition.initialize(d);
        }
    }
}