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 2010 Sun Microsystems, Inc.
015 * Portions copyright 2012-2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.ldap.responses;
018
019import java.util.List;
020
021import org.forgerock.opendj.ldap.DecodeException;
022import org.forgerock.opendj.ldap.DecodeOptions;
023import org.forgerock.opendj.ldap.ResultCode;
024import org.forgerock.opendj.ldap.controls.Control;
025import org.forgerock.opendj.ldap.controls.ControlDecoder;
026
027/**
028 * An Compare result indicates the final status of an Compare operation.
029 * <p>
030 * If the attribute value assertion in the Compare request matched a value of
031 * the attribute or sub-type according to the attribute's equality matching rule
032 * then the result code is set to {@link ResultCode#COMPARE_TRUE} and can be
033 * determined by invoking the {@link #matched} method.
034 * <p>
035 * The following excerpt shows how to use the Compare operation to check whether
036 * a member belongs to a (possibly large) static group.
037 *
038 * <pre>
039 * Connection connection = ...;
040 * String groupDN = ...;
041 * String memberDN = ...;
042 *
043 * CompareRequest request =
044 *         Requests.newCompareRequest(groupDN, "member", memberDN);
045 * CompareResult result = connection.compare(request);
046 * if (result.matched()) {
047 *     // The member belongs to the group.
048 * }
049 * </pre>
050 */
051public interface CompareResult extends Result {
052
053    @Override
054    CompareResult addControl(Control control);
055
056    @Override
057    CompareResult addReferralURI(String uri);
058
059    @Override
060    Throwable getCause();
061
062    @Override
063    <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options)
064            throws DecodeException;
065
066    @Override
067    List<Control> getControls();
068
069    @Override
070    String getDiagnosticMessage();
071
072    @Override
073    String getMatchedDN();
074
075    @Override
076    List<String> getReferralURIs();
077
078    @Override
079    ResultCode getResultCode();
080
081    @Override
082    boolean isReferral();
083
084    @Override
085    boolean isSuccess();
086
087    /**
088     * Indicates whether the attribute value assertion in the Compare
089     * request matched a value of the attribute or sub-type according to the
090     * attribute's equality matching rule.
091     * <p>
092     * Specifically, this method returns {@code true} if the result code is
093     * equal to {@link ResultCode#COMPARE_TRUE}.
094     *
095     * @return {@code true} if the attribute value assertion matched, otherwise
096     *         {@code false}.
097     */
098    boolean matched();
099
100    @Override
101    CompareResult setCause(Throwable cause);
102
103    @Override
104    CompareResult setDiagnosticMessage(String message);
105
106    @Override
107    CompareResult setMatchedDN(String dn);
108
109    @Override
110    CompareResult setResultCode(ResultCode resultCode);
111
112}