If a value is present, invoke the specified consumer with the value, otherwise do nothing.

@param consumer consumer to be invoked if present.
@return this Optional
@since 1.7.8
421804
public Optional<T> ifPresent(final Consumer<? super T> consumer) {
        if (isPresent()) {
            consumer.accept(get());
        }

        return this;
    }
844486
public void setConsumer(org.apache.kafka.clients.consumer.KafkaConsumer<Object, Object> consumer) {
        this.consumer = consumer;
    }
1283014
public static <T> Consumer<T> pipeline(Consumer<T> consumer) {
        return new PipelinedConsumer<T>(Iterations.iterable(consumer));
    }
506901
public static <T> void consumeIfNotNull(T target, Consumer<T> consumer) {
        Optional.ofNullable(target).ifPresent(consumer);
    }
312058
@SuppressWarnings("unchecked")
    public void forEach(final Consumer<V> consumer)
    {
        for (final Object value : values)
        {
            if (null != value)
            {
                consumer.accept((V)value);
            }
        }
    }
516945
public CompletableFuture<T> except(Consumer<Throwable> consumer) {
    return whenComplete((result, error) -> {
      if (error != null) {
        consumer.accept(error);
      }
    });
  }
1354815
public static <T, U, E extends Throwable> @NonNull BiConsumer<T, U> rethrowBiConsumer(final @NonNull ThrowingBiConsumer<T, U, E> consumer) {
    return consumer;
  }
902026
public FluentMatchingC<T> then(Consumer2<A, B> consumer) {
    return then(new FluentMatchingC<>(value), consumer);
  }
1329979
protected final void registerConsumer( AbstractMessageConsumer consumer )
    {
        if (consumersMap.put(consumer.getId(),consumer) != null)
        	throw new IllegalArgumentException("Consumer "+consumer.getId()+" already exists");
    }
744251
public T orElseDoAndReturnDefault(Consumer<Result<T>> consumer, T defaultVal) {
        if (isSuccessAndNotNull()) {
            return data;
        }
        consumer.accept(this);
        return defaultVal;
    }
158621
public void getView(final Consumer<Parent> consumer) {
		CompletableFuture.supplyAsync(this::getView, Platform::runLater).thenAccept(consumer);
	}
1133377
public static <T, U> BiConsumer<T, U> biConsumer(CheckedBiConsumer<T, U> consumer) {
        return Unchecked.biConsumer(consumer, Unchecked.RETHROW_ALL);
    }
469204
protected void invokeConsumer(Consumer<ProgressUpdate> consumer, ProgressUpdate progressUpdate) {
		try {
			consumer.accept(progressUpdate);
		} catch (Throwable t) {
			logger.error("Exception thrown by a Consumer<ProgressUpdate> consumer: " + consumer + "; progressUpdate: " + progressUpdate, t);
		}
	}
441051
public static <T, E extends Exception> Consumer<T> sneaked(SneakyConsumer<T, E> consumer) {
    return t -> {
      @SuppressWarnings("unchecked")
      SneakyConsumer<T, RuntimeException> casedConsumer =
          (SneakyConsumer<T, RuntimeException>) consumer;
      casedConsumer.accept(t);
    };
  }
894085
public void addConsumer(SnapshotConsumer consumer){
		if (consumers.contains(consumer))
			consumers.remove(consumer);
		consumers.add(consumer);
	}
1330545
public static <T> Position.Writable<T> writable(final Type type, Consumer<T> consumer) {
        return new W<>(Validate.notNull(type, "type"), Validate.notNull(consumer, "consumer"));
    }
204987
@Nonnull
	public static <T> ObjDoubleConsumerBuilder<T> objDblConsumer(Consumer<ObjDoubleConsumer<T>> consumer) {
		return new ObjDoubleConsumerBuilder(consumer);
	}