@Override public void handleTimedEvent(AddParcelEvent event, SimulatorAPI simulator) { final String name; if (counter >= ALPHABET_SIZE) { if (counter >= PARCEL_LIMIT) { throw new IllegalStateException( "Too many parcels, this handler is meant for debugging and should " + "not be used in production."); } final char first = (char) ('A' + (int) Math.floor(counter / ALPHABET_SIZE) - 1); final char second = (char) ('A' + counter % ALPHABET_SIZE); name = Chars.join("", first, second); } else { name = Character.toString((char) (counter + 'A')); } counter++; simulator.register( Parcel.builder(event.getParcelDTO()) .toString(name) .build()); }
@Override public void handleTimedEvent(AddParcelEvent event, SimulatorAPI simulator) { final String name; if (counter >= ALPHABET_SIZE) { if (counter >= PARCEL_LIMIT) { throw new IllegalStateException( "Too many parcels, this handler is meant for debugging and should " + "not be used in production."); } final char first = (char) ('A' + (int) Math.floor(counter / ALPHABET_SIZE) - 1); final char second = (char) ('A' + counter % ALPHABET_SIZE); name = Chars.join("", first, second); } else { name = Character.toString((char) (counter + 'A')); } counter++; simulator.register( Parcel.builder(event.getParcelDTO()) .toString(name) .build()); }