litesoft
Diff Revisions
626
vs
948
for /trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/NoEqualsUniqueCollector.java
|
@@ -1,17 +1,13 @@ |
1 |
1 |
|
package com.temp.shared.utils; |
2 |
2 |
|
|
3 |
|
- |
import java.util.ArrayList; |
4 |
|
- |
import java.util.Collection; |
5 |
|
- |
import java.util.HashSet; |
6 |
|
- |
import java.util.List; |
7 |
|
- |
import java.util.Set; |
|
3 |
+ |
import java.util.*; |
8 |
4 |
|
|
9 |
5 |
|
public class NoEqualsUniqueCollector<E, C extends Comparable<C>> { |
10 |
6 |
|
private final List<E> entries = new ArrayList<E>(); |
11 |
7 |
|
private final Set<C> uniqueKeys = new HashSet<C>(); |
12 |
8 |
|
private final NoEqualsHelper<E, C> helper; |
13 |
9 |
|
|
14 |
|
- |
public NoEqualsUniqueCollector(NoEqualsHelper<E, C> helper) { |
|
10 |
+ |
public NoEqualsUniqueCollector( NoEqualsHelper<E, C> helper ) { |
15 |
11 |
|
this.helper = helper; |
16 |
12 |
|
} |
17 |
13 |
|
|
|
@@ -19,25 +15,25 @@ |
19 |
15 |
|
return entries.isEmpty(); |
20 |
16 |
|
} |
21 |
17 |
|
|
22 |
|
- |
public void add(E entry) { |
23 |
|
- |
if ((entry != null) && uniqueKeys.add(helper.getProxyValue(entry))) { |
24 |
|
- |
entries.add(entry); |
|
18 |
+ |
public void add( E entry ) { |
|
19 |
+ |
if ( (entry != null) && uniqueKeys.add( helper.getProxyValue( entry ) ) ) { |
|
20 |
+ |
entries.add( entry ); |
25 |
21 |
|
} |
26 |
22 |
|
} |
27 |
23 |
|
|
28 |
|
- |
public void addAll(Collection<E> entries) { |
29 |
|
- |
if (entries != null) { |
30 |
|
- |
for (E entry : entries) { |
31 |
|
- |
add(entry); |
|
24 |
+ |
public void addAll( Collection<E> entries ) { |
|
25 |
+ |
if ( entries != null ) { |
|
26 |
+ |
for ( E entry : entries ) { |
|
27 |
+ |
add( entry ); |
32 |
28 |
|
} |
33 |
29 |
|
} |
34 |
30 |
|
} |
35 |
31 |
|
|
36 |
32 |
|
public E[] toArray() { |
37 |
|
- |
return entries.toArray(helper.createArray(entries.size())); |
|
33 |
+ |
return entries.toArray( helper.createArray( entries.size() ) ); |
38 |
34 |
|
} |
39 |
35 |
|
|
40 |
36 |
|
public List<E> toList() { |
41 |
|
- |
return new ArrayList<E>(entries); |
|
37 |
+ |
return new ArrayList<E>( entries ); |
42 |
38 |
|
} |
43 |
39 |
|
} |