Exemplo n.º 1
0
 @Override
 public boolean equals(Object obj) {
   if (obj instanceof LogoHashObject) {
     return Equality.equals(sourceObject, ((LogoHashObject) obj).getSourceObject());
   } else {
     return Equality.equals(sourceObject, obj);
   }
 }
Exemplo n.º 2
0
 @Override
 public Object report(final org.nlogo.nvm.Context context) throws LogoException {
   Object obj = args[1].report(context);
   if (obj instanceof LogoList) {
     Object value = args[0].report(context);
     LogoList list = (LogoList) obj;
     for (Iterator<Object> it = list.iterator(); it.hasNext(); ) {
       if (Equality.equals(value, it.next())) {
         return Boolean.TRUE;
       }
     }
     return Boolean.FALSE;
   } else if (obj instanceof String) {
     return ((String) obj).indexOf(argEvalString(context, 0)) != -1 ? Boolean.TRUE : Boolean.FALSE;
   } else if (obj instanceof AgentSet) {
     Agent agent = argEvalAgent(context, 0);
     AgentSet agentset = (AgentSet) obj;
     if (agent instanceof Turtle) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Turtle.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.turtles()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Turtle) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     }
     if (agent instanceof Link) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Link.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.links()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Link) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     } else if (agent instanceof Patch) {
       if (agentset.type() != Patch.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.patches()) {
         return Boolean.TRUE;
       }
     }
     return agentset.contains(agent) ? Boolean.TRUE : Boolean.FALSE;
   } else {
     throw new ArgumentTypeException(
         context, this, 1, Syntax.ListType() | Syntax.StringType() | Syntax.AgentsetType(), obj);
   }
 }