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-2009 Sun Microsystems, Inc.
025 */
026
027package org.forgerock.opendj.config;
028
029/**
030 * A visitor of relation definitions, in the style of the visitor design
031 * pattern. Classes implementing this interface can query relation definitions
032 * in a type-safe manner when the kind of relation definition is unknown at
033 * compile time. When a visitor is passed to a relation definition's accept
034 * method, the corresponding visit method most applicable to that relation
035 * definition is invoked.
036 *
037 * @param <R>
038 *            The return type of this visitor's methods. Use
039 *            {@link java.lang.Void} for visitors that do not need to return
040 *            results.
041 * @param <P>
042 *            The type of the additional parameter to this visitor's methods.
043 *            Use {@link java.lang.Void} for visitors that do not need an
044 *            additional parameter.
045 */
046public interface RelationDefinitionVisitor<R, P> {
047
048    /**
049     * Visit an instantiable relation definition.
050     *
051     * @param <C>
052     *            The type of client managed object configuration that the
053     *            relation definition refers to.
054     * @param <S>
055     *            The type of server managed object configuration that the
056     *            relation definition refers to.
057     * @param rd
058     *            The instantiable relation definition to visit.
059     * @param p
060     *            A visitor specified parameter.
061     * @return Returns a visitor specified result.
062     */
063    <C extends ConfigurationClient, S extends Configuration> R visitInstantiable(
064        InstantiableRelationDefinition<C, S> rd, P p);
065
066    /**
067     * Visit a set relation definition.
068     *
069     * @param <C>
070     *            The type of client managed object configuration that the
071     *            relation definition refers to.
072     * @param <S>
073     *            The type of server managed object configuration that the
074     *            relation definition refers to.
075     * @param rd
076     *            The set relation definition to visit.
077     * @param p
078     *            A visitor specified parameter.
079     * @return Returns a visitor specified result.
080     */
081    <C extends ConfigurationClient, S extends Configuration> R visitSet(SetRelationDefinition<C, S> rd, P p);
082
083    /**
084     * Visit an optional relation definition.
085     *
086     * @param <C>
087     *            The type of client managed object configuration that the
088     *            relation definition refers to.
089     * @param <S>
090     *            The type of server managed object configuration that the
091     *            relation definition refers to.
092     * @param rd
093     *            The optional relation definition to visit.
094     * @param p
095     *            A visitor specified parameter.
096     * @return Returns a visitor specified result.
097     */
098    <C extends ConfigurationClient, S extends Configuration> R visitOptional(OptionalRelationDefinition<C, S> rd, P p);
099
100    /**
101     * Visit a singleton relation definition.
102     *
103     * @param <C>
104     *            The type of client managed object configuration that the
105     *            relation definition refers to.
106     * @param <S>
107     *            The type of server managed object configuration that the
108     *            relation definition refers to.
109     * @param rd
110     *            The singleton relation definition to visit.
111     * @param p
112     *            A visitor specified parameter.
113     * @return Returns a visitor specified result.
114     */
115    <C extends ConfigurationClient, S extends Configuration> R visitSingleton(SingletonRelationDefinition<C, S> rd,
116        P p);
117
118}