From 6cd084e77f8d761a26f6e644993af3d77dd52b74 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sun, 16 Sep 2012 22:46:42 +0200 Subject: [PATCH] [#1830] Allow for passing null or empty arrays to intoMap(Field[]) and intoGroups(Field[]) --- jOOQ/src/main/java/org/jooq/Result.java | 6 ++++-- jOOQ/src/main/java/org/jooq/impl/ResultImpl.java | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/Result.java b/jOOQ/src/main/java/org/jooq/Result.java index ea8e4c2fa8..6b73defec6 100644 --- a/jOOQ/src/main/java/org/jooq/Result.java +++ b/jOOQ/src/main/java/org/jooq/Result.java @@ -1844,7 +1844,8 @@ public interface Result extends FieldProvider, List, Attach * are non-unique. * * @param keys The keys. Client code must assure that keys are unique in the - * result set. + * result set. If this is null or an empty array, + * the resulting map will contain at most one entry. * @return A Map containing the results. * @throws InvalidResultException if the keys are non-unique in the result * set. @@ -1886,7 +1887,8 @@ public interface Result extends FieldProvider, List, Attach * Unlike {@link #intoMap(Field[])}, this method allows for non-unique keys * in the result set. * - * @param keys The keys. + * @param keys The keys. If this is null or an empty array, the + * resulting map will contain at most one entry. * @return A Map containing grouped results */ Map, Result> intoGroups(Field[] keys); diff --git a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java index 658e4c93e6..5f5e556bce 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java @@ -1393,8 +1393,8 @@ class ResultImpl implements Result, AttachableInternal { @Override public final Map, R> intoMap(Field[] keys) { - if (keys == null || keys.length == 0) { - throw new IllegalArgumentException("Keys must not be null or empty."); + if (keys == null) { + keys = new Field[0]; } Map, R> map = new LinkedHashMap, R>(); @@ -1454,8 +1454,8 @@ class ResultImpl implements Result, AttachableInternal { @Override public final Map, Result> intoGroups(Field[] keys) { - if (keys == null || keys.length == 0) { - throw new IllegalArgumentException("Keys must not be null or empty."); + if (keys == null) { + keys = new Field[0]; } Map, Result> map = new LinkedHashMap, Result>();