Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents 179d263 + fe827ad commit dd57e92a95154cf3d483b8b28d0423239d05b32e @hakurai committed Nov 8, 2012
View
@@ -8,3 +8,4 @@ target/
immutable.properties
mutable.properties
normalUser.properties
+custom.properties
View
@@ -13,7 +13,7 @@ dependencies {
}
sourceCompatibility = 1.6
-version = '0.4.0'
+version = '0.4.1'
jar {
manifest {
attributes 'Implementation-Title': 'backlog4j', 'Implementation-Version': version
View
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
- <groupId>backlog4j</groupId>
+ <groupId>org.backlog4j</groupId>
<artifactId>backlog4j</artifactId>
- <version>0.4.0</version>
+ <version>0.4.1</version>
<packaging>jar</packaging>
<name>Backlog API</name>
@@ -59,16 +59,12 @@ public String getName() {
return (String) map.get(NAME);
}
- public UpdateCustomField addIssueType(Integer issueTypeId) {
- List<Integer> issueTypes = getIssueTypes();
- if (issueTypes == null) {
- issueTypes = new ArrayList<Integer>();
- map.put(ISSUE_TYPES, issueTypes);
- }
-
- issueTypes.add(issueTypeId);
+ public UpdateCustomField setIssueType(Integer issueTypeId) {
+ return setValue(ISSUE_TYPES, issueTypeId);
+ }
- return this;
+ public UpdateCustomField addIssueType(Integer issueTypeId) {
+ return addValue(ISSUE_TYPES, issueTypeId);
}
public List<Integer> getIssueTypes() {
@@ -175,16 +171,12 @@ public String getInitialDate() {
return (String) map.get(INITIAL_DATE);
}
- public UpdateCustomField addItem(String item) {
- List<String> items = getItems();
- if (items == null) {
- items = new ArrayList<String>();
- map.put(ITEMS, items);
- }
-
- items.add(item);
+ public UpdateCustomField setItem(String item) {
+ return setValue(ITEMS, item);
+ }
- return this;
+ public UpdateCustomField addItem(String item) {
+ return addValue(ITEMS, item);
}
public List<String> getItems() {
@@ -221,4 +213,25 @@ public CustomField execute() {
return CustomFieldParser.parse((Map<String, Object>) res);
}
+
+ protected <V> UpdateCustomField setValue(String name, V value) {
+ List<V> list = (List<V>) map.get(name);
+ if (list != null && !list.isEmpty()) {
+ list.clear();
+ }
+ addValue(name, value);
+
+ return this;
+ }
+
+ protected <V> UpdateCustomField addValue(String name, V value) {
+ List<V> list = (List<V>) map.get(name);
+ if (list == null) {
+ list = new ArrayList<V>();
+ map.put(name, list);
+ }
+ list.add(value);
+
+ return this;
+ }
}
Oops, something went wrong.

0 comments on commit dd57e92

Please sign in to comment.