Record Class CompareRequest

java.lang.Object
java.lang.Record
org.forgerock.opendj.ldap.messages.CompareRequest
Record Components:
name - the distinguished name of the entry to be compared. The server shall not dereference any aliases in locating the entry to be compared.
attributeDescription - the name of the attribute to be compared.
assertionValue - the assertion value to be compared.
controls - the List containing the controls.
All Implemented Interfaces:
ProtocolOp, Request

public record CompareRequest(Dn name, AttributeDescription attributeDescription, ByteString assertionValue, List<Control> controls) extends Record implements Request
The Compare operation allows a client to compare an assertion value with the values of a particular attribute in a particular entry in the Directory.

Note that some directory systems may establish access controls that permit the values of certain attributes (such as userPassword ) to be compared but not interrogated by other means.

The following excerpt shows how to use the Compare operation to check whether a member belongs to a (possibly large) static group.

 Connection connection = ...;
 String groupDN = ...;
 String memberDN = ...;

 CompareRequest request =
          Requests.newCompareRequest(groupDN, "member", memberDN);
 CompareResult result = connection.compare(request);
 if (result.matched()) {
     // The member belongs to the group.
 }
 
  • Constructor Details

  • Method Details

    • accept

      public <R, P, E extends Exception> R accept(RequestVisitor<R,P,E> v, P p) throws E
      Description copied from interface: Request
      Applies a RequestVisitor to this Request.
      Specified by:
      accept in interface Request
      Type Parameters:
      R - The return type of the visitor's methods.
      P - The type of the additional parameters to the visitor's methods.
      E - The type of the exception thrown by the visitor method if it fails, or NeverThrowsException if the visitor cannot fail.
      Parameters:
      v - The request visitor.
      p - Optional additional visitor parameter.
      Returns:
      A result as specified by the visitor.
      Throws:
      E - If the visitor failed.
    • getType

      public Request.RequestType getType()
      Description copied from interface: Request
      Returns the type of this request to avoid expensive instanceof checks.
      Specified by:
      getType in interface Request
      Returns:
      the type of this request
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public Dn name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • attributeDescription

      public AttributeDescription attributeDescription()
      Returns the value of the attributeDescription record component.
      Returns:
      the value of the attributeDescription record component
    • assertionValue

      public ByteString assertionValue()
      Returns the value of the assertionValue record component.
      Returns:
      the value of the assertionValue record component
    • controls

      public List<Control> controls()
      Returns the value of the controls record component.
      Specified by:
      controls in interface ProtocolOp
      Returns:
      the value of the controls record component