summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-04-09 09:44:31 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-04-09 09:44:31 -0700
commit115d9242bfb5d9e8bde7a89a6638dcdd3d53f2b1 (patch)
tree4e3cb47e1100fc658f35c66ce0219f8d8f926eb7 /src/main
parent8d5ffc1226f480e14d659a77a9a28ddbdf2e7119 (diff)
CustomFieldCollection is now case-insensitive.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/p4square/ccbapi/model/CustomFieldCollection.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/p4square/ccbapi/model/CustomFieldCollection.java b/src/main/java/com/p4square/ccbapi/model/CustomFieldCollection.java
index 0a1f87d..c49d070 100644
--- a/src/main/java/com/p4square/ccbapi/model/CustomFieldCollection.java
+++ b/src/main/java/com/p4square/ccbapi/model/CustomFieldCollection.java
@@ -26,7 +26,7 @@ public class CustomFieldCollection<T extends CustomField> implements Collection<
* @return The entry associated with the field.
*/
public T getByName(final String name) {
- return fieldNameToValue.get(name);
+ return fieldNameToValue.get(name.toLowerCase());
}
/**
@@ -36,7 +36,7 @@ public class CustomFieldCollection<T extends CustomField> implements Collection<
* @return The entry associated with the field.
*/
public T getByLabel(final String label) {
- return fieldLabelToValue.get(label);
+ return fieldLabelToValue.get(label.toLowerCase());
}
public List<T> asList() {
@@ -76,18 +76,18 @@ public class CustomFieldCollection<T extends CustomField> implements Collection<
@Override
public boolean add(final T t) {
// Clean up overwritten indexes.
- final T previousValueByName = fieldNameToValue.get(t.getName());
+ final T previousValueByName = fieldNameToValue.get(t.getName().toLowerCase());
if (previousValueByName != null) {
remove(previousValueByName);
}
- final T previousValueByLabel = fieldLabelToValue.get(t.getLabel());
+ final T previousValueByLabel = fieldLabelToValue.get(t.getLabel().toLowerCase());
if (previousValueByLabel != null) {
remove(previousValueByLabel);
}
- fieldNameToValue.put(t.getName(), t);
- fieldLabelToValue.put(t.getLabel(), t);
+ fieldNameToValue.put(t.getName().toLowerCase(), t);
+ fieldLabelToValue.put(t.getLabel().toLowerCase(), t);
return values.add(t);
}
@@ -95,8 +95,8 @@ public class CustomFieldCollection<T extends CustomField> implements Collection<
public boolean remove(final Object o) {
if (values.remove(o)) {
final T entry = (T) o;
- fieldNameToValue.remove(entry.getName());
- fieldLabelToValue.remove(entry.getLabel());
+ fieldNameToValue.remove(entry.getName().toLowerCase());
+ fieldLabelToValue.remove(entry.getLabel().toLowerCase());
return true;
}
return false;
@@ -132,6 +132,8 @@ public class CustomFieldCollection<T extends CustomField> implements Collection<
@Override
public void clear() {
+ fieldNameToValue.clear();
+ fieldLabelToValue.clear();
values.clear();
}
}