Skip to content

Commit

Permalink
Allow construction of Set, List, and Map fields for DataTypeAdapters
Browse files Browse the repository at this point in the history
  • Loading branch information
gitblit committed Jun 30, 2015
1 parent e664693 commit f8e9ed9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.moxie
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Iciql
description: 'a model-based database access wrapper for JDBC'
groupId: com.iciql
artifactId: iciql
version: 1.7.0-SNAPSHOT
version: 1.6.4-SNAPSHOT
packaging: jar+zip
inceptionYear: 2011

Expand Down
6 changes: 4 additions & 2 deletions releases.moxie
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ r28: {
security: ~
fixes: ~
changes: ~
additions: ~
additions:
- Support Set, List, and Map types for columns when used with DataTypeAdapter
dependencyChanges: ~
contributors: ~
contributors:
- James Moger
}

#
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/iciql/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -191,6 +193,15 @@ public static <T> T newObject(Class<T> clazz) {
} else if (clazz == java.util.UUID.class) {
COUNTER.getAndIncrement();
return (T) UUID.randomUUID();
} else if (Set.class == clazz) {
COUNTER.getAndIncrement();
return (T) new HashSet();
} else if (List.class == clazz) {
COUNTER.getAndIncrement();
return (T) new ArrayList();
} else if (Map.class == clazz) {
COUNTER.getAndIncrement();
return (T) new HashMap();
}
try {
return clazz.newInstance();
Expand Down

0 comments on commit f8e9ed9

Please sign in to comment.