Condition matching is not allowed in java in switch statements.
What you can do here is create an enum of your string literals, and using that enum create a helper function which returns the matched enum literal. Using that value of enum returned, you can easily apply switch case.
For example:
public enum Tags{
A("a"),
B("b"),
C("c"),
D("d");
private String tag;
private Tags(String tag)
{
this.tag=tag;
}
public String getTag(){
return this.tag;
}
public static Tags ifContains(String line){
for(Tags enumValue:values()){
if(line.contains(enumValue)){
return enumValue;
}
}
return null;
}
}
And inside your java matching class,do something like:
Tags matchedValue=Tags.ifContains("A");
if(matchedValue!=null){
switch(matchedValue){
case A:
break;
etc...
}