Revision 2212 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/namestranslator/AbstractNamesTranslator.java
AbstractNamesTranslator.java | ||
---|---|---|
30 | 30 |
import java.util.Iterator; |
31 | 31 |
import java.util.List; |
32 | 32 |
import java.util.Map; |
33 |
import java.util.Set; |
|
33 | 34 |
import java.util.function.Function; |
34 | 35 |
import org.apache.commons.lang3.StringUtils; |
35 | 36 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
46 | 47 |
*/ |
47 | 48 |
public abstract class AbstractNamesTranslator implements NamesTranslator, Persistent { |
48 | 49 |
|
49 |
protected class SimpleMap implements Cloneable { |
|
50 |
protected static class SimpleMap implements Cloneable {
|
|
50 | 51 |
|
51 | 52 |
public Map<String, String> map; |
52 | 53 |
|
... | ... | |
68 | 69 |
|
69 | 70 |
@Override |
70 | 71 |
public SimpleMap clone() throws CloneNotSupportedException { |
71 |
SimpleMap clone = new SimpleMap(); |
|
72 |
HashMap<String, String> newMap = new HashMap<>(); |
|
73 |
newMap.putAll(map); |
|
74 |
clone.map = newMap; |
|
72 |
SimpleMap clone = (SimpleMap) super.clone(); |
|
73 |
clone.map = new HashMap<>(this.map); |
|
75 | 74 |
return clone; |
76 | 75 |
} |
77 | 76 |
|
78 | 77 |
} |
79 | 78 |
|
80 |
protected class SimpleList implements Iterable<String>, Cloneable { |
|
79 |
protected static class SimpleList implements Iterable<String>, Cloneable {
|
|
81 | 80 |
|
82 | 81 |
public List<String> list; |
83 | 82 |
|
... | ... | |
87 | 86 |
|
88 | 87 |
@Override |
89 | 88 |
public SimpleList clone() throws CloneNotSupportedException { |
90 |
SimpleList clone = new SimpleList();
|
|
91 |
clone.toList().addAll(list);
|
|
89 |
SimpleList clone = (SimpleList) super.clone();
|
|
90 |
clone.list = new ArrayList<>(list);
|
|
92 | 91 |
return clone; |
93 | 92 |
} |
94 | 93 |
|
... | ... | |
135 | 134 |
return list.iterator(); |
136 | 135 |
|
137 | 136 |
} |
137 |
|
|
138 |
public boolean isEmpty() { |
|
139 |
return this.list.isEmpty(); |
|
140 |
} |
|
138 | 141 |
|
139 | 142 |
public List<String> toList() { |
140 | 143 |
return list; |
141 | 144 |
} |
142 | 145 |
|
143 | 146 |
public boolean hasUniqueValues() { |
144 |
HashSet<String> sourceNamesSet = new HashSet<String>();
|
|
147 |
Set<String> sourceNamesSet = new HashSet<>();
|
|
145 | 148 |
for (String sourceName : this.list) { |
146 | 149 |
sourceNamesSet.add(sourceName.toLowerCase()); |
147 | 150 |
} |
Also available in: Unified diff