/[projects]/dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/util/DeduplicateHelper.java
ViewVC logotype

Contents of /dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/util/DeduplicateHelper.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2815 - (show annotations) (download)
Thu Jan 14 18:03:16 2016 UTC (8 years, 4 months ago) by torben
File size: 650 byte(s)
Move more work into AliasGenerator
1 package dk.daoas.daoadresseservice.util;
2
3 import java.util.HashMap;
4
5 public class DeduplicateHelper<T> {
6 private HashMap<T,T> cache;
7
8 public DeduplicateHelper() {
9 cache = new HashMap<T,T>();
10 }
11
12 public DeduplicateHelper(int initialCapacity) {
13 cache = new HashMap<T,T>(initialCapacity);
14 }
15
16
17
18 public T getInstance(T newT) {
19 if (newT == null) {
20 return null;
21 }
22
23 T cachedT = cache.get(newT);
24 if ( cachedT == null ) {
25 cachedT = newT;
26 cache.put(newT, newT);
27 }
28 return cachedT;
29 }
30
31 public int size() {
32 return cache.size();
33 }
34
35 public void clear() {
36 cache.clear();
37 }
38
39 }

  ViewVC Help
Powered by ViewVC 1.1.20