I don’t know that I agree with the approach, but you could do
enum CanDos {
TALK,
WALK,
SLEEP,
SIT,
STARE
}
And then the class can have
abstract class Foo {
abstract Set<CanDos> getCanDos();
abstract boolean can(CanDos item);
}
And you can use it EnumSetfor effective storage capabilities.
, , Right Thing, (, , ), EnumSet<CanDos> - .
abstract class Foo {
private final Set<CanDos> candos;
protected Foo(Set<CanDos> candos)
{
this.candos = new EnumSet<CanDos>(candos);
}
public boolean can(CanDos item) {
return candos.contains(item);
}
}
(, , , , ). " Java" " ".
,
enum CanDos {
TALK,
WALK,
SLEEP,
SIT,
STARE
}
public interface FooThatCanDo {
boolean can(CanDos item);
}
, ( ), , , , implements FooThatCanDo.