Java
Код:
if (creature instanceof Player && isInSameTeam((Player) creature)) {
return true;
}
if (creature instanceof Trap && ((Trap) creature).getCreator().getObjectId().equals(getObjectId())) {
return true;
}
if (creature instanceof Kisk && ((Kisk) creature).canBind(this)) {
return true;
}
Scala
Код:
creature match {
case p: Player => isInSameTeam(p)
case t: Trap => t.getCreator().getObjectId() == getObjectId()
case k: Kisk => k.canBind(this)
}
PS: пример из Аиона