Merge pull request #6897 from eric239/feature/6868-prefer-public-constructors

[#6868] Prefer public constructors
This commit is contained in:
Lukas Eder 2017-12-11 09:56:59 +01:00 committed by GitHub
commit 87e9ba3215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -353,6 +353,10 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
// "matching" constructor with the same number of fields as this record
Constructor<E>[] constructors = (Constructor<E>[]) type.getDeclaredConstructors();
// [#6868] Prefer public constructors
Arrays.sort(constructors, (c1, c2) ->
(c2.getModifiers() & Modifier.PUBLIC) - (c1.getModifiers() & Modifier.PUBLIC));
// [#1837] If any java.beans.ConstructorProperties annotations are
// present use those rather than matching constructors by the number of
// arguments