com.github.siwenyan.dish_parser.Flavor Maven / Gradle / Ivy
package com.github.siwenyan.dish_parser;
import com.github.siwenyan.common.StringTools;
import java.util.regex.Matcher;
public class Flavor {
public enum FlavorPart {
TABLE_NAME, CUT_IN_AT, IS_DELICIOUS
}
private String raw = null;
private String flavor = null;
private String tableName = null;
private int cutinAt = -1;
private boolean isDelicious = false;
public Flavor(String sFlavorWithHints) throws BadSmellException {
this.raw = sFlavorWithHints;
if (sFlavorWithHints == null || sFlavorWithHints.trim().isEmpty()) {
throw new BadSmellException("Invalid name.");
}
Matcher matcher = SyntaxSimple.PATTERN_FLAVOR.matcher(sFlavorWithHints);
while (matcher.find()) {
String sDelicious = matcher.group(1);
String sFlavor = matcher.group(2);
String sTable = matcher.group(4);
String sCutinAt = matcher.group(6);
if (sFlavor == null) {
throw new BadSmellException("Missing name.");
}
this.flavor = sFlavor;
this.isDelicious = (sDelicious != null);
this.tableName = sTable;
this.cutinAt = StringTools.parsePositiveInteger(sCutinAt);
}
}
public String getFlavorName() {
return flavor;
}
public String getTableName() {
return tableName;
}
public int getCutinAt() {
return cutinAt;
}
public boolean isDelicious() {
return this.isDelicious;
}
public String getRaw() {
return raw;
}
public String toString() {
return this.raw;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy