Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KeyInfo implements Comparable<KeyInfo> {
- private final String id;
- private final type type;
- // --- コンストラクタ、Getter/Setterは省略 ---
- @Override
- public int compareTo(final KeyInfo info) {
- // TreeMap向け メソッド
- if(StringUtils.equals(info.id, this.id)
- && info.type == this.type)
- return 0;
- else
- return -1;
- }
- @Override
- public boolean equals(Object arg0) {
- // HashMap向け メソッド
- if(arg0 instanceof KeyInfo && compareTo((KeyInfo)arg0) == 0) {
- return true;
- }
- return super.equals(arg0);
- }
- @Override
- public int hashCode() {
- // HashMap向け メソッド
- return HashCodeBuilder.reflectionHashCode(this, new String[]{}/*exclude*/);
- }
- }
Add Comment
Please, Sign In to add comment