|
|
|
|
@ -50,8 +50,6 @@ public class PreferredConstructorDiscoverer<T> {
@@ -50,8 +50,6 @@ public class PreferredConstructorDiscoverer<T> {
|
|
|
|
|
*/ |
|
|
|
|
protected PreferredConstructorDiscoverer(TypeInformation<T> owningType) { |
|
|
|
|
|
|
|
|
|
boolean noArgConstructorFound = false; |
|
|
|
|
int numberOfArgConstructors = 0; |
|
|
|
|
Class<?> rawOwningType = owningType.getType(); |
|
|
|
|
|
|
|
|
|
for (Constructor<?> constructor : rawOwningType.getDeclaredConstructors()) { |
|
|
|
|
@ -65,24 +63,10 @@ public class PreferredConstructorDiscoverer<T> {
@@ -65,24 +63,10 @@ public class PreferredConstructorDiscoverer<T> {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// No-arg constructor trumps custom ones
|
|
|
|
|
if (this.constructor == null || preferredConstructor.isNoArgConstructor()) { |
|
|
|
|
this.constructor = preferredConstructor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (preferredConstructor.isNoArgConstructor()) { |
|
|
|
|
noArgConstructorFound = true; |
|
|
|
|
} else { |
|
|
|
|
numberOfArgConstructors++; |
|
|
|
|
this.constructor = preferredConstructor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!noArgConstructorFound && numberOfArgConstructors > 1) { |
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
String.format("Multiple constructors with arguments found in class %s! Annotate " + |
|
|
|
|
"one with @PersistenceConstructor explicitly to select it to be used in " + |
|
|
|
|
"persistence operations.", rawOwningType.getName())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|