Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. @SuppressWarnings("unchecked")
  2. public <T> T getAttribute(String key, Object fail) {
  3. if (attributes.containsKey(key))
  4. return (T) attributes.get(key);
  5. else
  6. return (T) fail;
  7. }
  8.  
  9. public <T> T getAttribute(String key, T fail) {
  10.  
  11. Object object = attributes.get(key);
  12.  
  13. if (object != null && object.getClass() == fail.getClass()) {
  14. @SuppressWarnings("unchecked")
  15. T t = (T) object;
  16. return t;
  17. }
  18. if (fail == null) {//wtf
  19. return null;
  20. }
  21.  
  22. return fail;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement