code: public static <S, T extends Event> InputMapTemplate<S, T> when(
              Predicate<? super S> condition, InputMapTemplate<S, T> imt) {
  
          return new InputMapTemplate<S, T>() {
              @Override
              protected InputHandlerTemplateMap<S, T> getInputHandlerTemplateMap() {
                  return imt.getInputHandlerTemplateMap().map(
                          h -> (s, evt) -> condition.test(s) ? h.process(s, evt) : Result.PROCEED);
              }
          };
      }
docs: When the given {@code condition} is true, pattern matches the event with the given {@link InputMap} or
  proceeds to the next {@code InputMap} (if it exists).