All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tonivade.purefun.Consumer1 Maven / Gradle / Ivy

/*
 * Copyright (c) 2018-2019, Antonio Gabriel Muñoz Conejo 
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.purefun;

import static com.github.tonivade.purefun.Unit.unit;

@FunctionalInterface
public interface Consumer1 {

  void accept(A value);

  default Function1 asFunction() {
    return value -> { accept(value); return unit(); };
  }

  default Consumer1 andThen(Consumer1 after) {
    return value -> { accept(value); after.accept(value); };
  }

  default Function1 peek() {
    return value -> { accept(value); return value; };
  }

  static  Consumer1 of(Consumer1 reference) {
    return reference;
  }

  static  Consumer1 noop() {
    return value -> { /* noop */ };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy