Package jsonvalues
Class Prism<S,T>
- java.lang.Object
-
- jsonvalues.Prism<S,T>
-
- Type Parameters:
S
- the source of a prismT
- the target of a prism
public class Prism<S,T> extends java.lang.Object
A Prism is an optic that can be seen as a pair of functions:- getOptional: S -> Optional<T> - reverseGet : T -> S
Typically a Prism encodes the relation between a Sum or CoProduct type and one of its element.
-
-
Field Summary
Fields Modifier and Type Field Description java.util.function.Function<java.util.function.Predicate<T>,java.util.function.Predicate<S>>
all
check if there is no target or the target satisfies the predicatejava.util.function.Function<java.util.function.Predicate<T>,java.util.function.Predicate<S>>
exists
check if there is a target and it satisfies the predicatejava.util.function.Function<java.util.function.Predicate<T>,java.util.function.Function<S,java.util.Optional<T>>>
find
find if the target satisfies the predicatejava.util.function.Function<S,java.util.Optional<T>>
getOptional
get the target of a Prism or nothing if there is no targetjava.util.function.Predicate<S>
isEmpty
check if there is no targetjava.util.function.Function<java.util.function.Function<T,T>,java.util.function.Function<S,S>>
modify
modify the target of a Prism with a function, returning the same source if the prism is not matching.java.util.function.Function<java.util.function.Function<T,T>,java.util.function.Function<S,java.util.Optional<S>>>
modifyOpt
modify the target of a Prism with a function, returning empty if the prism is not matching.java.util.function.Predicate<S>
nonEmpty
check if there is a targetjava.util.function.Function<T,S>
reverseGet
get the modified source of a Prism
-
-
-
Field Detail
-
getOptional
public final java.util.function.Function<S,java.util.Optional<T>> getOptional
get the target of a Prism or nothing if there is no target
-
reverseGet
public final java.util.function.Function<T,S> reverseGet
get the modified source of a Prism
-
isEmpty
public final java.util.function.Predicate<S> isEmpty
check if there is no target
-
nonEmpty
public final java.util.function.Predicate<S> nonEmpty
check if there is a target
-
modify
public final java.util.function.Function<java.util.function.Function<T,T>,java.util.function.Function<S,S>> modify
modify the target of a Prism with a function, returning the same source if the prism is not matching. Basically it means we dont care about the success of the operation
-
modifyOpt
public final java.util.function.Function<java.util.function.Function<T,T>,java.util.function.Function<S,java.util.Optional<S>>> modifyOpt
modify the target of a Prism with a function, returning empty if the prism is not matching. Unless modify, we need to know the success of the operation
-
find
public final java.util.function.Function<java.util.function.Predicate<T>,java.util.function.Function<S,java.util.Optional<T>>> find
find if the target satisfies the predicate
-
exists
public final java.util.function.Function<java.util.function.Predicate<T>,java.util.function.Predicate<S>> exists
check if there is a target and it satisfies the predicate
-
-