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 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 Function<Predicate<T>,Predicate<S>>
all
check if there is no target or the target satisfies the predicateFunction<Predicate<T>,Predicate<S>>
exists
check if there is a target and it satisfies the predicateFunction<Predicate<T>,Function<S,Optional<T>>>
find
find if the target satisfies the predicateFunction<S,Optional<T>>
getOptional
get the target of a Prism or nothing if there is no targetPredicate<S>
isEmpty
check if there is no targetFunction<Function<T,T>,Function<S,S>>
modify
modify the target of a Prism with a function, returning the same source if the prism is not matching.Function<Function<T,T>,Function<S,Optional<S>>>
modifyOpt
modify the target of a Prism with a function, returning empty if the prism is not matching.Predicate<S>
nonEmpty
check if there is a targetFunction<T,S>
reverseGet
get the modified source of a Prism
-
-
-
Field Detail
-
getOptional
public final Function<S,Optional<T>> getOptional
get the target of a Prism or nothing if there is no target
-
modify
public final Function<Function<T,T>,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 Function<Function<T,T>,Function<S,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 Function<Predicate<T>,Function<S,Optional<T>>> find
find if the target satisfies the predicate
-
exists
public final Function<Predicate<T>,Predicate<S>> exists
check if there is a target and it satisfies the predicate
-
-