Class Functions
java.lang.Object
org.forgerock.opendj.ldap.Functions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctions.BiConsumer<T, U, E extends Exception>ABiConsumerfunctional interface which can throw a checked Exception.static interfaceFunctions.BiPredicate<T, U, E extends Exception>ABiPredicatefunctional interface which can throw a checked Exception.static interfaceFunctions.ToIntFunction<T, E extends Exception>AToIntFunctionfunctional interface which can throw a checked Exception. -
Method Summary
Modifier and TypeMethodDescriptionstatic AttributeDescriptionbyteStringToAttributeDescription(ByteString value, Schema schema) Parses aByteStringas anAttributeDescriptionusing the provided schema.Returns a function which parsesBooleanvalues.static X509CertificateParses aByteStringas aX509Certificate.Returns a function which parsesDNs using the default schema.byteStringToDn(Schema schema) Returns a function which parsesDNs using the provided schema.static DurationbyteStringToDuration(ByteString value) Parses aByteStringas aDurationusing ourDurationUnitparser.Returns a function which parses generalized time strings.Returns a function which parsesIntegerstring values.Returns a function which parsesLongstring values.Returns a function which parsesPathstring values.static <M,N> Function <M, N, NeverThrowsException> constant(N constant) Creates a function that returns constant value for any input.Returns an empty action for RxJava and ForgeRock.Returns an empty consumer for RxJava, JDK and ForgeRock.static <M> Midentity(M value) Returns the provided value.static <R, E extends Exception>
ToIntFunction<R> rethrowIntFunction(Functions.ToIntFunction<R, E> function) Wrap a throwingFunctions.ToIntFunctionto comply withToIntFunction's no checked exception signature.static booleanstringToBoolean(String value) Parses aStringas aboolean.static intstringToInteger(String value) Parses aStringas anint.static longstringToLong(String value) Parses aStringas along.static PathstringToPath(String value) static URIstringToUri(String value)
-
Method Details
-
constant
Creates a function that returns constant value for any input.- Type Parameters:
M- The type of input values transformed by this function.N- The type of output values returned by this function.- Parameters:
constant- The constant value for the function to return- Returns:
- A function that always returns constant value.
-
emptyConsumer
public static <T, E extends Exception, C extends Consumer<T> & Consumer<T> & Consumer<T,E>> C emptyConsumer()Returns an empty consumer for RxJava, JDK and ForgeRock.- Type Parameters:
T- the expected value type to be consumedE- the expected exception that may be thrownC- type of the returned consumer- Returns:
- an empty consumer for RxJava, JDK and ForgeRock
-
emptyAction
-
identity
public static <M> M identity(M value) Returns the provided value.- Type Parameters:
M- The type of value returned by this function.- Parameters:
value- The value to be returned.- Returns:
- the provided value
-
stringToBoolean
Parses aStringas aboolean. The method will accept the values0,false,no,off,1,true,yes,on. All other values will result in aLocalizedIllegalArgumentException.- Parameters:
value- The value to be parsed.- Returns:
- The parsed
boolean.
-
stringToInteger
Parses aStringas anint. Invalid values will result in aLocalizedIllegalArgumentException.- Parameters:
value- The value to be parsed.- Returns:
- The parsed
int.
-
stringToLong
Parses aStringas along. Invalid values will result in aLocalizedIllegalArgumentException.- Parameters:
value- The value to be parsed.- Returns:
- The parsed
long.
-
stringToPath
-
stringToUri
-
byteStringToAttributeDescription
public static AttributeDescription byteStringToAttributeDescription(ByteString value, Schema schema) Parses aByteStringas anAttributeDescriptionusing the provided schema. Invalid values will result in aLocalizedIllegalArgumentException.- Parameters:
value- The value to be parsed.schema- The schema to use for decoding attribute descriptions.- Returns:
- The parsed
AttributeDescriptions.
-
byteStringToBoolean
public static Function<ByteString, Boolean, LocalizedIllegalArgumentException> byteStringToBoolean()Returns a function which parsesBooleanvalues. The function will accept the values0,false,no,off,1,true,yes,on. All other values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses
Booleanvalues.
-
byteStringToDn
Returns a function which parsesDNs using the default schema. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses
DNs.
-
byteStringToDn
public static Function<ByteString, Dn, LocalizedIllegalArgumentException> byteStringToDn(Schema schema) Returns a function which parsesDNs using the provided schema. Invalid values will result in aLocalizedIllegalArgumentException.- Parameters:
schema- The schema to use for decoding DNs.- Returns:
- A function which parses
DNs.
-
byteStringToDuration
Parses aByteStringas aDurationusing ourDurationUnitparser. Invalid values will result in aLocalizedIllegalArgumentException- Parameters:
value- The value to be parsed.- Returns:
- The parsed
Duration
-
byteStringToCertificate
Parses aByteStringas aX509Certificate. Invalid values will result in aLocalizedIllegalArgumentException.- Parameters:
value- The value to be parsed.- Returns:
- The parsed
X509Certificate.
-
byteStringToGeneralizedTime
public static Function<ByteString, GeneralizedTime, LocalizedIllegalArgumentException> byteStringToGeneralizedTime()Returns a function which parses generalized time strings. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses generalized time strings.
-
byteStringToInteger
public static Function<ByteString, Integer, LocalizedIllegalArgumentException> byteStringToInteger()Returns a function which parsesIntegerstring values. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses
Integerstring values.
-
byteStringToLong
Returns a function which parsesLongstring values. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses
Longstring values.
-
byteStringToPath
Returns a function which parsesPathstring values. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- a function which parses
Pathstring values
-
rethrowIntFunction
public static <R, E extends Exception> ToIntFunction<R> rethrowIntFunction(Functions.ToIntFunction<R, E> function) throws EWrap a throwingFunctions.ToIntFunctionto comply withToIntFunction's no checked exception signature. The underlying exception will actually be thrown and must be handled by the client code.WARNING: See the class-level javadoc for safety considerations governing use of this method.
- Type Parameters:
R- The type of the result.E- The type of exception thrown.- Parameters:
function- TheFunctions.ToIntFunctionthat throws the checked exception- Returns:
- A
ToIntFunctionthat does not appear to throw the checked exception. - Throws:
E- This method does not really throwE- the compiler is tricked into thinking it does.
-