Class SimplePropertyMapper

java.lang.Object
org.forgerock.opendj.rest2ldap.PropertyMapper
org.forgerock.opendj.rest2ldap.SimplePropertyMapper

public final class SimplePropertyMapper extends PropertyMapper
An property mapper which provides a simple mapping from a JSON value to a single LDAP attribute.
  • Method Details

    • decoder

      public SimplePropertyMapper decoder(Function<ByteString,?,? extends Exception> f)
      Sets the decoder which will be used for converting LDAP attribute values to JSON values.
      Parameters:
      f - The function to use for decoding LDAP attribute values.
      Returns:
      This property mapper.
    • defaultJsonValue

      public SimplePropertyMapper defaultJsonValue(Object defaultValue)
      Sets the default JSON value which should be substituted when the LDAP attribute is not found in the LDAP entry.
      Parameters:
      defaultValue - The default JSON value.
      Returns:
      This property mapper.
    • defaultJsonValues

      public SimplePropertyMapper defaultJsonValues(Collection<?> defaultValues)
      Sets the default JSON values which should be substituted when the LDAP attribute is not found in the LDAP entry.
      Parameters:
      defaultValues - The default JSON values.
      Returns:
      This property mapper.
    • encoder

      public SimplePropertyMapper encoder(Function<Object,ByteString,? extends Exception> f)
      Sets the encoder which will be used for converting JSON values to LDAP attribute values.
      Parameters:
      f - The function to use for encoding LDAP attribute values.
      Returns:
      This property mapper.
    • isBinary

      public SimplePropertyMapper isBinary(boolean isBinary)
      Indicates that JSON values are base 64 encodings of binary data. Calling this method with the value true is equivalent to the following:
       mapper.decoder(...); // function that converts binary data to base 64
       mapper.encoder(...); // function that converts base 64 to binary data
       
      Passing in a value of false resets the encoding and decoding functions to the default.
      Parameters:
      isBinary - true if this property is binary.
      Returns:
      This property mapper.
    • jsonSchema

      public SimplePropertyMapper jsonSchema(JsonValue jsonSchema)
      Sets the JSON schema corresponding to this simple property mapper. If not null, it will be returned by toJsonSchema(), otherwise a default JSON schema will be automatically generated with the information available in this property mapper.
      Parameters:
      jsonSchema - the JSON schema corresponding to this simple property mapper. Can be null
      Returns:
      This property mapper.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • putTypeAndFormat

      public static void putTypeAndFormat(JsonValue jsonSchema, AttributeType attrType)
      Puts the type and format corresponding to the provided attribute type on the provided JSON schema.
      Parameters:
      jsonSchema - the JSON schema where to put the type and format
      attrType - the attribute type for which to infer JSON the type and format
      See Also:
    • isRequired

      public final SimplePropertyMapper isRequired(boolean isRequired)
      Indicates that the LDAP attribute is mandatory and must be provided during create requests.
      Parameters:
      isRequired - true if this property is required.
      Returns:
      This property mapper.
    • isMultiValued

      public final SimplePropertyMapper isMultiValued(boolean isMultiValued)
      Indicates that the LDAP attribute is multi-valued and should be represented in JSON using an array of values.
      Parameters:
      isMultiValued - true if this property is multi-valued.
      Returns:
      This property mapper.
    • writability

      public final SimplePropertyMapper writability(WritabilityPolicy policy)
      Indicates whether the LDAP attribute supports updates. The default is WritabilityPolicy.READ_WRITE.
      Parameters:
      policy - The writability policy.
      Returns:
      This property mapper.
    • putWritabilityProperties

      public static void putWritabilityProperties(WritabilityPolicy writabilityPolicy, JsonValue jsonSchema)