[DOMA4104] アクセッサメソッド[getValue]が見つかりません。アクセッサメソッドは、型[java.lang.Integer]を戻り値とする非privateで引数なしのインスタンスメソッドでなければいけません。
Created
December 11, 2012 08:49
-
-
Save gakuzzzz/4257111 to your computer and use it in GitHub Desktop.
Doma の Domain定義の共通化
This file contains 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
import java.io.Serializable; | |
import static com.google.common.base.Preconditions.checkNotNull; | |
public class AbstractDomain<T extends Comparable<T>, REPR extends AbstractDomain<T, REPR>> implements Serializable, Comparable<REPR> { | |
private static final long serialVersionUID = 1L; | |
private final T value; | |
public AbstractDomain(final T value) { | |
checkNotNull(value); | |
this.value = value; | |
} | |
public T getValue() { | |
return value; | |
} | |
@Override | |
public String toString() { | |
return value.toString(); | |
} | |
@Override | |
public int hashCode() { | |
return value.hashCode(); | |
} | |
public boolean canEqual(final Object other) { | |
return getClass().isInstance(other); | |
} | |
@Override | |
public boolean equals(final Object obj) { | |
if (this == obj) return true; | |
if (obj == null) return false; | |
if (!getClass().isInstance(obj)) return false; | |
final AbstractDomain<?, ?> other = getClass().cast(obj); | |
return other.canEqual(this) && value.equals(other.value); | |
} | |
@Override | |
public int compareTo(final REPR o) { | |
checkNotNull(o); | |
return getValue().compareTo(o.getValue()); | |
} | |
} |
This file contains 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
import org.seasar.doma.Domain; | |
@Domain(valueType = Integer.class) | |
public final class AccountId extends AbstractDomain<Integer, AccountId> { | |
private static final long serialVersionUID = 1L; | |
public AccountId(final Integer value) { | |
super(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment