-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #983 from sania-16/working
ZIP Changes - Draft PR
- Loading branch information
Showing
115 changed files
with
1,442 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
common/client/src/main/java/zingg/common/client/IMatchType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
|
106 changes: 44 additions & 62 deletions
106
common/client/src/main/java/zingg/common/client/MatchType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(){ | ||
|
||
} | ||
|
||
/** | ||
* 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; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
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; | ||
} | ||
|
||
} |
Oops, something went wrong.