001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2014 ForgeRock AS
026 */
027package org.forgerock.opendj.config.conditions;
028
029import org.forgerock.opendj.config.AbstractManagedObjectDefinition;
030import org.forgerock.opendj.config.client.ManagedObject;
031import org.forgerock.opendj.config.client.ManagementContext;
032import org.forgerock.opendj.config.server.ConfigException;
033import org.forgerock.opendj.config.server.ServerManagedObject;
034import org.forgerock.opendj.ldap.LdapException;
035
036/**
037 * An interface for evaluating conditions.
038 */
039public interface Condition {
040
041    /**
042     * Initializes this condition.
043     *
044     * @param d
045     *            The abstract managed object definition associated with this
046     *            condition.
047     * @throws Exception
048     *             If this condition could not be initialized.
049     */
050    void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception;
051
052    /**
053     * Evaluates this condition against the provided client managed object.
054     *
055     * @param context
056     *            The client management context.
057     * @param managedObject
058     *            The client managed object.
059     * @return Returns <code>true</code> if this condition is satisfied.
060     * @throws LdapException
061     *             If the condition could not be evaluated.
062     */
063    boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException;
064
065    /**
066     * Evaluates this condition against the provided server managed object.
067     *
068     * @param managedObject
069     *            The server managed object.
070     * @return Returns <code>true</code> if this condition is satisfied.
071     * @throws ConfigException
072     *             If the condition could not be evaluated due to an unexpected
073     *             configuration exception.
074     */
075    boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException;
076}