001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 * Portions Copyright 2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.config;
018
019/**
020 * This interface is used to determine the "best match" managed object
021 * definition in a definition hierarchy.
022 * <p>
023 * Managed object definitions, like Java classes, are arranged in an inheritance
024 * hierarchy. When managed objects are decoded (e.g. from LDAP entries), the
025 * driver implementation is provided with an
026 * "expected managed object definition". However, the actual decoded managed
027 * object is often an instance of a sub-type of this definition. For example,
028 * when decoding a connection handler managed object, the actual type can never
029 * be a connection handler because it is an abstract managed object type.
030 * Instead, the decoded managed object must be a "concrete" sub-type: an LDAP
031 * connection handler or JMX connection handler.
032 * <p>
033 * This resolution process is coordinated by the
034 * <code>resolveManagedObjectDefinition</code> method in managed object
035 * definitions, where it is passed a <code>DefinitionResolver</code>
036 * implementation. The <code>resolveManagedObjectDefinition</code> method takes
037 * care of recursively descending through the definition hierarchy and invokes
038 * the {@link #matches(AbstractManagedObjectDefinition)} method against each
039 * potential sub-type. It is the job of the resolver to indicate whether the
040 * provided managed object definition is a candidate definition. For example,
041 * the LDAP driver provides a definition resolver which uses the decoded LDAP
042 * entry's object classes to determine the final appropriate managed object
043 * definition.
044 */
045public interface DefinitionResolver {
046
047    /**
048     * Determines whether the provided managed object definition matches
049     * this resolver's criteria.
050     *
051     * @param d
052     *            The managed object definition.
053     * @return Returns <code>true</code> if the the provided managed object
054     *         definition matches this resolver's criteria.
055     */
056    boolean matches(AbstractManagedObjectDefinition<?, ?> d);
057}