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 2009 Sun Microsystems, Inc.
025 */
026
027package org.forgerock.opendj.ldif;
028
029import org.forgerock.opendj.ldap.requests.AddRequest;
030import org.forgerock.opendj.ldap.requests.DeleteRequest;
031import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
032import org.forgerock.opendj.ldap.requests.ModifyRequest;
033
034/**
035 * A visitor of {@code ChangeRecord}s, in the style of the visitor design
036 * pattern.
037 * <p>
038 * Classes implementing this interface can query change records in a type-safe
039 * manner. When a visitor is passed to a change record's accept method, the
040 * corresponding visit method most applicable to that change record is invoked.
041 *
042 * @param <R>
043 *            The return type of this visitor's methods. Use
044 *            {@link java.lang.Void} for visitors that do not need to return
045 *            results.
046 * @param <P>
047 *            The type of the additional parameter to this visitor's methods.
048 *            Use {@link java.lang.Void} for visitors that do not need an
049 *            additional parameter.
050 */
051public interface ChangeRecordVisitor<R, P> {
052
053    /**
054     * Visits an {@code Add} change record.
055     *
056     * @param p
057     *            A visitor specified parameter.
058     * @param change
059     *            The {@code Add} change record.
060     * @return Returns a visitor specified result.
061     */
062    R visitChangeRecord(P p, AddRequest change);
063
064    /**
065     * Visits an {@code Delete} change record.
066     *
067     * @param p
068     *            A visitor specified parameter.
069     * @param change
070     *            The {@code Delete} change record.
071     * @return Returns a visitor specified result.
072     */
073    R visitChangeRecord(P p, DeleteRequest change);
074
075    /**
076     * Visits an {@code ModifyDN} change record.
077     *
078     * @param p
079     *            A visitor specified parameter.
080     * @param change
081     *            The {@code ModifyDN} change record.
082     * @return Returns a visitor specified result.
083     */
084    R visitChangeRecord(P p, ModifyDNRequest change);
085
086    /**
087     * Visits an {@code Modify} change record.
088     *
089     * @param p
090     *            A visitor specified parameter.
091     * @param change
092     *            The {@code Modify} change record.
093     * @return Returns a visitor specified result.
094     */
095    R visitChangeRecord(P p, ModifyRequest change);
096
097}