Created
November 1, 2012 16:41
-
-
Save alalwww/3994923 to your computer and use it in GitHub Desktop.
ItemFinder
This file contains hidden or 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
public static <I extends Item> I findItemByName(String targetName) | |
{ | |
if (!targetName.startsWith("item.")) | |
{ | |
targetName = "item." + targetName; | |
} | |
for (Item item : Item.itemsList) | |
{ | |
if (item == null || item.getItemName() == null) | |
{ | |
continue; | |
} | |
String name = item.getItemName(); | |
if (name.hashCode() == targetName.hashCode() && name.equals(targetName)) | |
{ | |
return (I) item; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment