Skip to content

Commit bc3c37c

Browse files
committed
Minor adjustment
- or() requires Java 9 - License years
1 parent 94d2561 commit bc3c37c

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -710,21 +710,22 @@ private Optional<Constructor<?>> findConstructorForAutomapping(final Class<?> re
710710
if (constructors.length == 1) {
711711
return Optional.of(constructors[0]);
712712
}
713-
return Arrays.stream(constructors)
714-
.filter(x -> x.isAnnotationPresent(AutomapConstructor.class))
715-
.reduce((x, y) -> {
716-
throw new ExecutorException("@AutomapConstructor should be used in only one constructor.");
717-
}).or(() -> {
718-
if (configuration.isArgNameBasedConstructorAutoMapping()) {
719-
// Finding-best-match type implementation is possible,
720-
// but using @AutomapConstructor seems sufficient.
721-
throw new ExecutorException(MessageFormat.format(
722-
"'argNameBasedConstructorAutoMapping' is enabled and the class ''{0}'' has multiple constructors, so @AutomapConstructor must be added to one of the constructors.",
723-
resultType.getName()));
724-
} else {
725-
return Arrays.stream(constructors).filter(x -> findUsableConstructorByArgTypes(x, rsw.getJdbcTypes())).findAny();
726-
}
727-
});
713+
Optional<Constructor<?>> reduce = Arrays.stream(constructors)
714+
.filter(x -> x.isAnnotationPresent(AutomapConstructor.class))
715+
.reduce((x, y) -> {
716+
throw new ExecutorException("@AutomapConstructor should be used in only one constructor.");
717+
});
718+
if (reduce.isPresent()) {
719+
return reduce;
720+
} else if (configuration.isArgNameBasedConstructorAutoMapping()) {
721+
// Finding-best-match type implementation is possible,
722+
// but using @AutomapConstructor seems sufficient.
723+
throw new ExecutorException(MessageFormat.format(
724+
"'argNameBasedConstructorAutoMapping' is enabled and the class ''{0}'' has multiple constructors, so @AutomapConstructor must be added to one of the constructors.",
725+
resultType.getName()));
726+
} else {
727+
return Arrays.stream(constructors).filter(x -> findUsableConstructorByArgTypes(x, rsw.getJdbcTypes())).findAny();
728+
}
728729
}
729730

730731
private boolean findUsableConstructorByArgTypes(final Constructor<?> constructor, final List<JdbcType> jdbcTypes) {

src/test/java/org/apache/ibatis/autoconstructor/AutoConstructorMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/org/apache/ibatis/autoconstructor/AutoConstructorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2021 the original author or authors.
2+
* Copyright 2009-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)