Package org.forgerock.opendj.rest2ldap
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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SimplePropertyMapper
decoder(Function<ByteString,?,? extends Exception> f)
Sets the decoder which will be used for converting LDAP attribute values to JSON values.SimplePropertyMapper
defaultJsonValue(Object defaultValue)
Sets the default JSON value which should be substituted when the LDAP attribute is not found in the LDAP entry.SimplePropertyMapper
defaultJsonValues(Collection<?> defaultValues)
Sets the default JSON values which should be substituted when the LDAP attribute is not found in the LDAP entry.SimplePropertyMapper
encoder(Function<Object,ByteString,? extends Exception> f)
Sets the encoder which will be used for converting JSON values to LDAP attribute values.SimplePropertyMapper
isBinary(boolean isBinary)
Indicates that JSON values are base 64 encodings of binary data.T
isMultiValued(boolean isMultiValued)
Indicates that the LDAP attribute is multi-valued and should be represented in JSON using an array of values.T
isRequired(boolean isRequired)
Indicates that the LDAP attribute is mandatory and must be provided during create requests.SimplePropertyMapper
jsonSchema(JsonValue jsonSchema)
Sets the JSON schema corresponding to this simple property mapper.static void
putTypeAndFormat(JsonValue jsonSchema, AttributeType attrType)
Puts the type and format corresponding to the provided attribute type on the provided JSON schema.static void
putWritabilityProperties(WritabilityPolicy writabilityPolicy, JsonValue jsonSchema)
String
toString()
T
writability(WritabilityPolicy policy)
Indicates whether the LDAP attribute supports updates.
-
-
-
Method Detail
-
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 valuetrue
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 offalse
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 notnull
, it will be returned bytoJsonSchema()
, 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 benull
- Returns:
- This property mapper.
-
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 formatattrType
- the attribute type for which to infer JSON the type and format- See Also:
- OpenAPI Specification 2.0, draft-fge-json-schema-validation-00 - Semantic validation with "format" - Defined attributes
-
isRequired
public final T 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 T 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 T writability(WritabilityPolicy policy)
Indicates whether the LDAP attribute supports updates. The default isWritabilityPolicy.READ_WRITE
.- Parameters:
policy
- The writability policy.- Returns:
- This property mapper.
-
putWritabilityProperties
public static void putWritabilityProperties(WritabilityPolicy writabilityPolicy, JsonValue jsonSchema)
-
-