| | |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.services.context.Context; |
| | | import org.forgerock.util.Function; |
| | | import org.forgerock.util.promise.NeverThrowsException; |
| | | import org.forgerock.util.promise.Promise; |
| | | |
| | | import static java.util.Collections.*; |
| | |
| | | |
| | | /** An property mapper which provides a simple mapping from a JSON value to a single LDAP attribute. */ |
| | | public final class SimplePropertyMapper extends AbstractLdapPropertyMapper<SimplePropertyMapper> { |
| | | private Function<ByteString, ?, NeverThrowsException> decoder; |
| | | private Function<Object, ByteString, NeverThrowsException> encoder; |
| | | private Function<ByteString, ?, ? extends Exception> decoder; |
| | | private Function<Object, ByteString, ? extends Exception> encoder; |
| | | |
| | | SimplePropertyMapper(final AttributeDescription ldapAttributeName) { |
| | | super(ldapAttributeName); |
| | |
| | | * The function to use for decoding LDAP attribute values. |
| | | * @return This property mapper. |
| | | */ |
| | | public SimplePropertyMapper decoder(final Function<ByteString, ?, NeverThrowsException> f) { |
| | | public SimplePropertyMapper decoder(final Function<ByteString, ?, ? extends Exception> f) { |
| | | this.decoder = f; |
| | | return this; |
| | | } |
| | |
| | | * The function to use for encoding LDAP attribute values. |
| | | * @return This property mapper. |
| | | */ |
| | | public SimplePropertyMapper encoder(final Function<Object, ByteString, NeverThrowsException> f) { |
| | | public SimplePropertyMapper encoder(final Function<Object, ByteString, ? extends Exception> f) { |
| | | this.encoder = f; |
| | | return this; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private Function<ByteString, ?, NeverThrowsException> decoder() { |
| | | private Function<ByteString, ?, ? extends Exception> decoder() { |
| | | return decoder == null ? byteStringToJson(ldapAttributeName) : decoder; |
| | | } |
| | | |
| | | private Function<Object, ByteString, NeverThrowsException> encoder() { |
| | | private Function<Object, ByteString, ? extends Exception> encoder() { |
| | | return encoder == null ? jsonToByteString(ldapAttributeName) : encoder; |
| | | } |
| | | |