r2227 - trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util
Author: tchemit Date: 2011-03-17 10:59:22 +0100 (Thu, 17 Mar 2011) New Revision: 2227 Url: http://nuiton.org/repositories/revision/topia/2227 Log: improve TopiaentityMap Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java 2011-03-17 09:56:17 UTC (rev 2226) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java 2011-03-17 09:59:22 UTC (rev 2227) @@ -63,8 +63,13 @@ * @param e the entity on which to find the key. * @return the key of the given entity. */ - protected abstract K getType(TopiaEntity e); + protected abstract K getType(Class<?> e); + public <T extends V> List<T> get(Class<T> type) { + K key = getType(type); + List<T> vs = (List<T>) get(key); + return vs; + } /** * Adds the given entity to the dictonary only if it does not exists. @@ -97,7 +102,7 @@ @SuppressWarnings({"unchecked"}) protected <T extends V> List<T> getList(T entity) { - K type = getType(entity); + K type = getType(entity.getClass()); List<T> list = (List<T>) get(type); if (list == null) { list = new ArrayList<T>();
participants (1)
-
tchemit@users.nuiton.org