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