次のように、Javaに列挙型クラスがあります
public enum SMethod {
/**
* LEAVE IN THIS ORDER
*/
A (true, true, true,false),
B (true, true, false,false),
C (true, true, false,false),
D (false, false, false)
}
別のクラスには以下のメソッドがあります
private String getSMethod(boolean isSds) {
if (isClsSds)
return "A";
else
return "B";
}
現在、このメソッドはハードコード値を返しますが、文字列です。しかし、SMethod enum を使用して返したいと考えています。次のように記述しました。
private SMethod getSMethod(boolean isSds) {
if (isClsSds)
return SMethod.A;
else
return SMethod.B;
}
しかし、私の必要性は、このメソッドが文字列を返す必要があることです。