-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package zingg.common.client; | ||
|
||
public interface IMatchType extends Named { | ||
|
||
public String getValue(); | ||
Check warning Code scanning / PMD Unnecessary modifier 'private' on constructor 'LabelMatchType(Double, String)': enum constructors are implicitly private Warning
Unnecessary modifier 'public' on method 'getValue': the method is declared in an interface type
|
||
|
||
public void setValue(String value); | ||
Check warning Code scanning / PMD Unnecessary modifier 'private' on constructor 'LabelMatchType(Double, String)': enum constructors are implicitly private Warning
Unnecessary modifier 'public' on method 'setValue': the method is declared in an interface type
|
||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package zingg.common.client; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class MatchTypes { | ||
Check warning Code scanning / PMD This utility class has a non-private constructor Warning
This utility class has a non-private constructor
|
||
|
||
public final static IMatchType FUZZY = new MatchType("FUZZY"); | ||
public final static IMatchType EXACT = new MatchType("EXACT"); | ||
public final static IMatchType PINCODE = new MatchType("PINCODE"); | ||
public final static IMatchType EMAIL = new MatchType("EMAIL"); | ||
public final static IMatchType TEXT = new MatchType("TEXT"); | ||
public final static IMatchType NUMERIC = new MatchType("NUMERIC"); | ||
public final static IMatchType NUMERIC_WITH_UNITS = new MatchType("NUMERIC_WITH_UNITS"); | ||
public final static IMatchType NULL_OR_BLANK = new MatchType("NULL_OR_BLANK"); | ||
public final static IMatchType ONLY_ALPHABETS_EXACT = new MatchType("ONLY_ALPHABETS_EXACT"); | ||
public final static IMatchType ONLY_ALPHABETS_FUZZY = new MatchType("ONLY_ALPHABETS_FUZZY"); | ||
public final static IMatchType DONT_USE = new MatchType("DONT_USE"); | ||
|
||
public static Map<String, IMatchType> allMatchTypes;// = new HashMap<String, IMatchType>(); | ||
|
||
protected MatchTypes(){ | ||
Check warning Code scanning / PMD Document empty constructor Warning
Document empty constructor
|
||
|
||
} | ||
|
||
public static final void put(IMatchType o) { | ||
|
||
if (allMatchTypes == null) { | ||
allMatchTypes = new HashMap<String, IMatchType>(); | ||
} | ||
Check warning Code scanning / PMD Singleton is not thread safe Warning
Singleton is not thread safe
|
||
|
||
allMatchTypes.put(o.getName(), o); | ||
} | ||
|
||
public static String[] getAllMatchTypes() { | ||
IMatchType[] zo = allMatchTypes.values().toArray(new IMatchType[allMatchTypes.size()]); | ||
Check warning Code scanning / PMD This call to Collection.toArray() may be optimizable Warning
This call to Collection.toArray() may be optimizable
|
||
int i = 0; | ||
String[] s = new String[zo.length]; | ||
for (IMatchType z: zo) { | ||
s[i++] = z.getName(); | ||
} | ||
return s; | ||
} | ||
|
||
public static final IMatchType getByValue(String value){ | ||
|
||
for (IMatchType zo: MatchTypes.allMatchTypes.values()) { | ||
Check warning Code scanning / PMD Unnecessary qualifier 'LabelMatchType': 'values' is already in scope Warning
Unnecessary qualifier 'MatchTypes': 'allMatchTypes' is already in scope because it is declared in an enclosing type
|
||
if (zo.getName().equals(value)) | ||
return zo; | ||
Check warning Code scanning / PMD This statement should have braces Warning
This statement should have braces
|
||
} | ||
return null; | ||
} | ||
|
||
} |