我有一個數組,我可以從中獲取字符串名稱。比較字符串與多個字符串(最佳數據結構)
arr[i].getName();
我想辦法與此相比,一些字符串我現在有他們他們在一個枚舉如下:
public enum BlockManValEnum {
SecurityID("SecurityID"),
BlockStatus("BlockStatus"),
Side("Side"),
GTBookingInst("GTBookingInst");
private String name;
private BlockManValEnum(String name) {
this.name = name;
}
public String toString() {
return this.name;
}
}
我想要的方式來檢查元素的數組,如果它匹配其中一個屬性,然後執行額外的功能,如果它不匹配不擔心它。我知道枚舉是完全錯誤的方式來存儲這個。
但是,我能想到的唯一方法是用String鍵創建一個只返回一個真正的布爾值的地圖。 (這似乎有點骯髒)