33 lines
687 B
Java
33 lines
687 B
Java
package com.banesco.common.domain.model;
|
|
|
|
import lombok.Getter;
|
|
|
|
@Getter
|
|
public class Either<L, R> {
|
|
private final L left;
|
|
private final R right;
|
|
|
|
private final boolean leftFlag;
|
|
|
|
private Either(L left, R right, boolean leftFlag) {
|
|
this.left = left;
|
|
this.right = right;
|
|
this.leftFlag = leftFlag;
|
|
}
|
|
|
|
public static <L, R> Either<L, R> left(L left) {
|
|
return new Either<>(left, null, true);
|
|
}
|
|
|
|
public static <L, R> Either<L, R> right(R right) {
|
|
return new Either<>(null, right, false);
|
|
}
|
|
|
|
public boolean isLeft() {
|
|
return leftFlag;
|
|
}
|
|
|
|
public boolean isRight() {
|
|
return !leftFlag;
|
|
}
|
|
} |