Guest User

Untitled

a guest
Jul 15th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public class KeyInfo implements Comparable<KeyInfo> {
  2. private final String id;
  3. private final type type;
  4.  
  5. // --- コンストラクタ、Getter/Setterは省略 ---
  6.  
  7. @Override
  8. public int compareTo(final KeyInfo info) {
  9. // TreeMap向け メソッド
  10. if(StringUtils.equals(info.id, this.id)
  11. && info.type == this.type)
  12. return 0;
  13. else
  14. return -1;
  15. }
  16. @Override
  17. public boolean equals(Object arg0) {
  18. // HashMap向け メソッド
  19. if(arg0 instanceof KeyInfo && compareTo((KeyInfo)arg0) == 0) {
  20. return true;
  21. }
  22. return super.equals(arg0);
  23. }
  24. @Override
  25. public int hashCode() {
  26. // HashMap向け メソッド
  27. return HashCodeBuilder.reflectionHashCode(this, new String[]{}/*exclude*/);
  28. }
  29. }
Add Comment
Please, Sign In to add comment