Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("unchecked")
- public <T> T getAttribute(String key, Object fail) {
- if (attributes.containsKey(key))
- return (T) attributes.get(key);
- else
- return (T) fail;
- }
- public <T> T getAttribute(String key, T fail) {
- Object object = attributes.get(key);
- if (object != null && object.getClass() == fail.getClass()) {
- @SuppressWarnings("unchecked")
- T t = (T) object;
- return t;
- }
- if (fail == null) {//wtf
- return null;
- }
- return fail;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement