Package javascalautils
Class Right<L,R>
- java.lang.Object
-
- javascalautils.Right<L,R>
-
- Type Parameters:
L
- The type for theLeft
side (not used for this class)R
- The type for theRight
side
- All Implemented Interfaces:
java.io.Serializable
,Either<L,R>
public final class Right<L,R> extends java.lang.Object implements Either<L,R>, java.io.Serializable
- Since:
- 1.1
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
fold(java.util.function.Function<L,T> func_left, java.util.function.Function<R,T> func_right)
Applies the providedfunc_right
to the wrapped value and returns the result.boolean
isRight()
Always returnstrue
.Either<R,L>
swap()
Returns aLeft
containing the value for this instance.java.lang.String
toString()
Returns a String representation of the instance.
-
-
-
Constructor Detail
-
Right
public Right(R value)
Creates an instance wrapping the provide value.- Parameters:
value
- The value wrapped by this instance- Since:
- 1.1
-
-
Method Detail
-
fold
public <T> T fold(java.util.function.Function<L,T> func_left, java.util.function.Function<R,T> func_right)
Applies the providedfunc_right
to the wrapped value and returns the result.- Specified by:
fold
in interfaceEither<L,R>
- Type Parameters:
T
- The type to return fromfunc_left/func_right
- Parameters:
func_left
- The function to apply in case this is aLeft
func_right
- The function to apply in case this is aRight
- Returns:
- The result from applying either func_left or func_right
- Since:
- 1.1
-
isRight
public boolean isRight()
Always returnstrue
.
-
toString
public java.lang.String toString()
Returns a String representation of the instance.- Overrides:
toString
in classjava.lang.Object
- Since:
- 1.1
-
-