Example #1
0
 /**
  * Calls {@link #add(int)} or {@link #remove} with the parameters defined by the configuration.
  *
  * @return always false
  */
 public final boolean execute() {
   if (add == 0) return false;
   if (!substitute) {
     if ((maxsize <= Network.size() && add > 0) || (minsize >= Network.size() && add < 0))
       return false;
   }
   int toadd = 0;
   int toremove = 0;
   if (add > 0) {
     toadd = (int) Math.round(add < 1 ? add * Network.size() : add);
     if (!substitute && toadd > maxsize - Network.size()) toadd = maxsize - Network.size();
     if (substitute) toremove = toadd;
   } else if (add < 0) {
     toremove = (int) Math.round(add > -1 ? -add * Network.size() : -add);
     if (!substitute && toremove > Network.size() - minsize) toremove = Network.size() - minsize;
     if (substitute) toadd = toremove;
   }
   remove(toremove);
   add(toadd);
   return false;
 }