Source:
private RoutineCharacteristics getRoutineCharacteristics(SqlBaseParser.RoutineCharacteristicsContext context) { Language language = null; Determinism determinism = null; NullCallClause nullCallClause = null; for (SqlBaseParser.RoutineCharacteristicContext characteristic : context.routineCharacteristic()) { if (characteristic.language() != null) { checkArgument(characteristic.language().SQL() != null, "Unsupported language: %s", characteristic.language().getText()); if (language != null) { throw new ParsingException(format("Duplicate language clause: %s", characteristic.language().getText()), getLocation(characteristic.language())); } language = Language.SQL; } else if (characteristic.determinism() != null) { if (determinism != null) { throw new ParsingException(format("Duplicate deterministic characteristics: %s", characteristic.determinism().getText()), getLocation(characteristic.determinism())); } determinism = characteristic.determinism().NOT() == null ? DETERMINISTIC : NOT_DETERMINISTIC; } else if (characteristic.nullCallClause() != null) { if (nullCallClause != null) { throw new ParsingException(format("Duplicate null-call clause: %s", characteristic.nullCallClause().getText()), getLocation(characteristic.nullCallClause())); } nullCallClause = characteristic.nullCallClause().CALLED() != null ? CALLED_ON_NULL_INPUT : RETURNS_NULL_ON_NULL_INPUT; } else { throw new IllegalArgumentException(format("Unsupported RoutineCharacteristic: %s", characteristic.getText())); } } return new RoutineCharacteristics( Optional.ofNullable(language), Optional.ofNullable(determinism), Optional.ofNullable(nullCallClause)); }

Target:
private RoutineCharacteristics getRoutineCharacteristics(SqlBaseParser.RoutineCharacteristicsContext context) { Language language = null; Determinism determinism = null; NullCallClause nullCallClause = null; for (SqlBaseParser.RoutineCharacteristicContext characteristic : context.routineCharacteristic()) { if (characteristic.language() != null) { checkArgument(characteristic.language().SQL() != null, "Unsupported language: %s", characteristic.language().getText()); if (language != null) { throw new ParsingException(format("Duplicate language clause: %s", characteristic.language().getText()), getLocation(characteristic.language())); } language = Language.SQL; } else if (characteristic.determinism() != null) { if (determinism != null) { throw new ParsingException(format("Duplicate determinism characteristics: %s", characteristic.determinism().getText()), getLocation(characteristic.determinism())); } determinism = characteristic.determinism().NOT() == null ? DETERMINISTIC : NOT_DETERMINISTIC; } else if (characteristic.nullCallClause() != null) { if (nullCallClause != null) { throw new ParsingException(format("Duplicate null-call clause: %s", characteristic.nullCallClause().getText()), getLocation(characteristic.nullCallClause())); } nullCallClause = characteristic.nullCallClause().CALLED() != null ? CALLED_ON_NULL_INPUT : RETURNS_NULL_ON_NULL_INPUT; } else { throw new IllegalArgumentException(format("Unsupported RoutineCharacteristic: %s", characteristic.getText())); } } return new RoutineCharacteristics( Optional.ofNullable(language), Optional.ofNullable(determinism), Optional.ofNullable(nullCallClause)); }