/** * Returns the Left value wrapped in this Either. * * @return The Left value wrapped in this Either * * @throws UnsupportedOperationException If this Either wraps a Right value instead */ public L getLeft() { if (!isLeft()) { LOG.error(String.format(ErrorMessageFormat.EITHER_ERROR_LEFT_OF_RIGHT.getLoggingFormat(), this)); throw new UnsupportedOperationException(ErrorMessageFormat.EITHER_ERROR_LEFT_OF_RIGHT.format(this)); } return left; }
/** * Returns the Right value wrapped in this Either. * * @return The Right value wrapped in this Either * * @throws UnsupportedOperationException If this Either wraps a Left value instead */ public R getRight() { if (isLeft()) { LOG.error(String.format(ErrorMessageFormat.EITHER_ERROR_RIGHT_OF_LEFT.getLoggingFormat(), this)); throw new UnsupportedOperationException(ErrorMessageFormat.EITHER_ERROR_RIGHT_OF_LEFT.format(this)); } return right; } }