/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(Consumer<T> consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(ByteConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(ShortConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(DoubleConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(IntConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(CharConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(FloatConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }
/** * If a value is present, invoke the specified consumer with the value, * otherwise invoke the function passed as the second parameter. * * @param consumer block to be executed if a value is present * @param function block to be executed if a value is absent */ public void ifPresentOrElse(LongConsumer consumer, Function function) { if (isPresent()) { consumer.consume(value); } else { function.call(); } }