merge CharSet getInstance/constructor String[] and String forms to String...

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1088339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2011-04-03 17:14:50 +00:00
parent 3541b7848a
commit 125aa57018
1 changed files with 9 additions and 30 deletions

View File

@ -135,45 +135,24 @@ public class CharSet implements Serializable {
*
* <p>All CharSet objects returned by this method will be immutable.</p>
*
* @param setStr the String describing the set, may be null
* @return a CharSet instance
* @since 2.0
*/
public static CharSet getInstance(String setStr) {
Object set = COMMON.get(setStr);
if (set != null) {
return (CharSet) set;
}
return new CharSet(setStr);
}
/**
* <p>Constructs a new CharSet using the set syntax.
* Each string is merged in with the set.</p>
*
* @param setStrs Strings to merge into the initial set, may be null
* @param setStrs Strings to merge into the set, may be null
* @return a CharSet instance
* @since 2.4
*/
public static CharSet getInstance(String[] setStrs) {
public static CharSet getInstance(String... setStrs) {
if (setStrs == null) {
return null;
}
if (setStrs.length == 1) {
CharSet common = COMMON.get(setStrs[0]);
if (common != null) {
return common;
}
}
return new CharSet(setStrs);
}
//-----------------------------------------------------------------------
/**
* <p>Constructs a new CharSet using the set syntax.</p>
*
* @param setStr the String describing the set, may be null
* @since 2.0
*/
protected CharSet(String setStr) {
super();
add(setStr);
}
/**
* <p>Constructs a new CharSet using the set syntax.
* Each string is merged in with the set.</p>
@ -181,7 +160,7 @@ protected CharSet(String setStr) {
* @param set Strings to merge into the initial set
* @throws NullPointerException if set is {@code null}
*/
protected CharSet(String[] set) {
protected CharSet(String... set) {
super();
int sz = set.length;
for (int i = 0; i < sz; i++) {