Skip to content

Commit

Permalink
Add getFirstString method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-gh committed Aug 27, 2016
1 parent 0d95068 commit 403576e
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,30 @@ public static void main( String... args )
prev = c;
}
}

// plugin-meta: Add getFirstString method
/**
* Returns the first string in this {@link ComparableVersion}. Usually this
* refers to the qualifier of the version.
*
* @return The first string, or null if not found
*/
public String getFirstString() {
return getFirstString(items);
}
private static String getFirstString(ListItem items) {
for (Item item : items) {
if (item instanceof StringItem) {
return ((StringItem) item).value;
} else if (item instanceof ListItem) {
String result = getFirstString((ListItem) item);
if (result != null) {
return result;
}
}
}

return null;
}

}

0 comments on commit 403576e

Please sign in to comment.