@Override
protected Boolean deserializeImpl(final String product) {
- switch (product) {
- case "true":
- return Boolean.TRUE;
- case "false":
- return Boolean.FALSE;
- default:
- throw new IllegalArgumentException("Invalid value '" + product + "' for boolean type. Allowed values "
- + "are 'true' and 'false'");
- }
+ return switch (product) {
+ case "true" -> Boolean.TRUE;
+ case "false" -> Boolean.FALSE;
+ default -> throw new IllegalArgumentException(
+ "Invalid value '" + product + "' for boolean type. Allowed values are 'true' and 'false'");
+ };
}
@Override
private final boolean invert;
CompiledPatternContext(final PatternConstraint yangConstraint) {
- this.constraint = requireNonNull(yangConstraint);
+ constraint = requireNonNull(yangConstraint);
pattern = Pattern.compile(yangConstraint.getJavaPatternString());
final Optional<ModifierKind> optModifier = yangConstraint.getModifier();
if (optModifier.isPresent()) {
- final ModifierKind modifier = optModifier.get();
- switch (modifier) {
- case INVERT_MATCH:
- invert = true;
- break;
- default:
- throw new IllegalStateException("Unhandled modifier " + modifier);
- }
+ invert = switch (optModifier.orElseThrow()) {
+ case INVERT_MATCH -> true;
+ };
} else {
invert = false;
}