Class EitherVisitor<A,B,T>
- java.lang.Object
-
- org.intermine.webservice.server.core.EitherVisitor<A,B,T>
-
- Type Parameters:
T
- The return type.A
- The left type.B
- The right type.
- Direct Known Subclasses:
TreeWalker
public abstract class EitherVisitor<A,B,T> extends java.lang.Object implements Function<Either<A,B>,T>
A mapping function capable of accessing a disjoint sum-type (an Either A B).- Author:
- Alex Kalderimis
-
-
Constructor Summary
Constructors Constructor Description EitherVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <R> EitherVisitor<A,B,R>
and(EitherVisitor<A,B,R> next)
Compose this visitor with another visitor which handles the either after this one has had a go at it, presumably for side-effects like logging and what-not.T
call(Either<A,B> either)
Take an A and return a B.<R> EitherVisitor<A,B,R>
then(Function<T,R> fn)
Compose this visitor with a function which consumes the output of this visitor.abstract T
visitLeft(A a)
Override this to access the left hand side.abstract T
visitRight(B b)
Override this to access the right hand side.
-
-
-
Method Detail
-
visitLeft
public abstract T visitLeft(A a)
Override this to access the left hand side.- Parameters:
a
- The content of the left.- Returns:
- A T of some kind
-
visitRight
public abstract T visitRight(B b)
Override this to access the right hand side.- Parameters:
b
- The content of the right- Returns:
- A T of some kind
-
call
public T call(Either<A,B> either)
Description copied from interface:Function
Take an A and return a B.
-
and
public <R> EitherVisitor<A,B,R> and(EitherVisitor<A,B,R> next)
Compose this visitor with another visitor which handles the either after this one has had a go at it, presumably for side-effects like logging and what-not.- Type Parameters:
R
- The return type.- Parameters:
next
- The visitor to handle the either after this one.- Returns:
- An R of some kind.
-
then
public <R> EitherVisitor<A,B,R> then(Function<T,R> fn)
Compose this visitor with a function which consumes the output of this visitor.- Type Parameters:
R
- The return type.- Parameters:
fn
- The function to pass the result to.- Returns:
- An R of some kind.
-
-