-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZIP Changes - Draft PR #983
base: mappings
Are you sure you want to change the base?
Changes from 57 commits
4f25d72
da9b54b
a111a3d
9a25242
b3b297a
aba0c96
afdb198
ae76694
4a64918
7ad79c4
bc85251
b9e72f2
c192629
9309e37
18452e3
ef4e2db
f2a2625
2c923d2
a357bf5
88d7a68
6d35db4
23b0be5
ca4c7e7
dcc7a91
10e9bae
059e94e
2f57793
e6726ba
d8fc1f6
9859f0e
8c11982
e09c74b
195340e
2425639
f11f77b
bb70609
176804a
1f2d833
b92f07d
11a5fcc
f224752
5eb9598
f3bcc46
07d1ac5
3c548db
af7bde3
6ecf80b
159f428
a458d8a
4e6d947
647390e
2f9b57c
013eeeb
328d414
b1e73a0
bfffee2
d387f7b
d75daca
fb0f503
d342f48
22368da
c69adbe
a7837b3
77fdb33
cd50ead
58846a1
76a7a0d
fb45d94
b09b31b
3202412
31d7580
434e551
48e1464
c922b09
5ee5de6
0753628
276e4d3
8604da8
58bac3a
4f3b065
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zingg.common.client; | ||
|
||
public interface IMatchType extends Named { | ||
|
||
public String toString(); | ||
Check warning Code scanning / PMD The method 'compare(String, String)' is missing an @Override annotation. Warning
The method 'toString()' is missing an @Override annotation.
Check warning Code scanning / PMD Unnecessary modifier 'private' on constructor 'LabelMatchType(Double, String)': enum constructors are implicitly private Warning
Unnecessary modifier 'public' on method 'toString': the method is declared in an interface type
|
||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,68 @@ | ||
package zingg.common.client; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Field types used in defining the types of fields for matching. See the field | ||
* definitions and the user guide for more details | ||
*/ | ||
|
||
public enum MatchType implements Serializable { | ||
/** | ||
* Short words like first names and organizations with focus on first | ||
* characters matching | ||
*/ | ||
FUZZY("FUZZY"), | ||
|
||
/** | ||
* Fields needing exact matches | ||
*/ | ||
EXACT("EXACT"), | ||
public class MatchType implements IMatchType, Serializable{ | ||
|
||
|
||
/** | ||
* Many times pin code is xxxxx-xxxx and has to be matched with xxxxx. | ||
*/ | ||
PINCODE("PINCODE"), | ||
private static final long serialVersionUID = 1L; | ||
public String name; | ||
|
||
/** | ||
* an email type which is supposed to look at only the first part of the email and ignore the domain. | ||
*/ | ||
EMAIL("EMAIL"), | ||
|
||
/** | ||
* Long descriptive text, usually more than a couple of words for example | ||
* product descriptions | ||
*/ | ||
TEXT("TEXT"), | ||
public MatchType(){ | ||
Check warning Code scanning / PMD Document empty constructor Warning
Document empty constructor
|
||
|
||
} | ||
|
||
/** | ||
* Strings containing numbers which need to be same. Example in addresses, | ||
* we dont want 4th street to match 5th street | ||
* Matching numbers with deviations | ||
*/ | ||
NUMERIC("NUMERIC"), | ||
/*eg P301d, P00231*/ | ||
NUMERIC_WITH_UNITS("NUMBER_WITH_UNITS"), | ||
NULL_OR_BLANK("NULL_OR_BLANK"), | ||
ONLY_ALPHABETS_EXACT("ONLY_ALPHABETS_EXACT"), | ||
ONLY_ALPHABETS_FUZZY("ONLY_ALPHABETS_FUZZY"), | ||
DONT_USE("DONT_USE"); | ||
public MatchType(String n){ | ||
this.name = n; | ||
MatchTypes.put(this); | ||
} | ||
|
||
private String value; | ||
private static Map<String, MatchType> types; | ||
@Override | ||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
MatchType(String type) { | ||
this.value = type; | ||
@Override | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
private static void init() { | ||
types = new HashMap<String, MatchType>(); | ||
for (MatchType f : MatchType.values()) { | ||
types.put(f.value, f); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((name == null) ? 0 : name.hashCode()); | ||
return result; | ||
} | ||
|
||
@JsonCreator | ||
public static MatchType getMatchType(String t) throws ZinggClientException{ | ||
if (types == null) { | ||
init(); | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
Check warning Code scanning / PMD This statement should have braces Warning
This statement should have braces
|
||
if (obj == null) | ||
return false; | ||
Check warning Code scanning / PMD This statement should have braces Warning
This statement should have braces
|
||
if (getClass() != obj.getClass()) | ||
return false; | ||
Check warning Code scanning / PMD This statement should have braces Warning
This statement should have braces
|
||
MatchType other = (MatchType) obj; | ||
if (name == null) { | ||
if (other.name != null){ | ||
return false; | ||
} | ||
} | ||
else if (!name.equalsIgnoreCase(other.name)){ | ||
return false; | ||
|
||
} | ||
MatchType type = types.get(t.trim().toUpperCase()); | ||
if (type == null) throw new ZinggClientException("Unsupported Match Type: " + t); | ||
return type; | ||
return true; | ||
} | ||
|
||
@JsonValue | ||
public String value() { | ||
return value; | ||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
|
||
} |
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>(); | ||
} | ||
Comment on lines
+28
to
+30
Check warning Code scanning / PMD Singleton is not thread safe Warning
Singleton is not thread safe
|
||
|
||
allMatchTypes.put(o.getName().toUpperCase(), 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 IMatchType getByName(String name) throws Exception{ | ||
for (IMatchType zo: MatchTypes.allMatchTypes.values()) { | ||
|
||
if (zo.getName().equalsIgnoreCase(name)) { | ||
return zo; | ||
|
||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
Check warning
Code scanning / PMD
Useless parentheses. Warning