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

com.codepoetics.fluvius.api.Conditional Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package com.codepoetics.fluvius.api;

import com.codepoetics.fluvius.api.functional.Mapper;

/**
 * A value with an attached Condition.
 *
 * @param  The type of the value.
 */
public final class Conditional {

  public static  Conditional of(Condition condition, V value) {
    return new Conditional<>(condition, value);
  }

  private final V value;
  private final Condition condition;

  private Conditional(Condition condition, V value) {
    this.value = value;
    this.condition = condition;
  }

  /**
   * Get the Condition associated with the value.
   *
   * @return The Condition associated with the value.
   */
  public Condition getCondition() {
    return condition;
  }

  /**
   * Get the value.
   *
   * @return The value.
   */
  public V getValue() {
    return value;
  }

  public  Conditional map(Mapper mapper) {
    return new Conditional<>(condition, mapper.apply(value));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy