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

com.github.messenger4j.send.message.template.receipt.Summary Maven / Gradle / Ivy

// Generated by delombok at Tue May 07 22:31:27 CEST 2019
package com.github.messenger4j.send.message.template.receipt;

import static java.util.Optional.empty;

import java.util.Optional;
import lombok.NonNull;

/**
 * @author Max Grabenhorst
 * @since 1.0.0
 */
public final class Summary {
  private final float totalCost;
  private final Optional subtotal;
  private final Optional totalTax;
  private final Optional shippingCost;

  private Summary(
      float totalCost,
      Optional subtotal,
      Optional totalTax,
      Optional shippingCost) {
    this.totalCost = totalCost;
    this.subtotal = subtotal;
    this.totalTax = totalTax;
    this.shippingCost = shippingCost;
  }

  public static Summary create(float totalCost) {
    return create(totalCost, empty(), empty(), empty());
  }

  public static Summary create(
      float totalCost,
      @NonNull Optional subtotal,
      @NonNull Optional totalTax,
      @NonNull Optional shippingCost) {
    if (subtotal == null) {
      throw new java.lang.IllegalArgumentException("subtotal is marked @NonNull but is null");
    }
    if (totalTax == null) {
      throw new java.lang.IllegalArgumentException("totalTax is marked @NonNull but is null");
    }
    if (shippingCost == null) {
      throw new java.lang.IllegalArgumentException("shippingCost is marked @NonNull but is null");
    }
    return new Summary(totalCost, subtotal, totalTax, shippingCost);
  }

  public float totalCost() {
    return totalCost;
  }

  public Optional subtotal() {
    return subtotal;
  }

  public Optional totalTax() {
    return totalTax;
  }

  public Optional shippingCost() {
    return shippingCost;
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public java.lang.String toString() {
    return "Summary(totalCost="
        + this.totalCost
        + ", subtotal="
        + this.subtotal
        + ", totalTax="
        + this.totalTax
        + ", shippingCost="
        + this.shippingCost
        + ")";
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public boolean equals(final java.lang.Object o) {
    if (o == this) return true;
    if (!(o instanceof Summary)) return false;
    final Summary other = (Summary) o;
    if (java.lang.Float.compare(this.totalCost, other.totalCost) != 0) return false;
    final java.lang.Object this$subtotal = this.subtotal;
    final java.lang.Object other$subtotal = other.subtotal;
    if (this$subtotal == null ? other$subtotal != null : !this$subtotal.equals(other$subtotal))
      return false;
    final java.lang.Object this$totalTax = this.totalTax;
    final java.lang.Object other$totalTax = other.totalTax;
    if (this$totalTax == null ? other$totalTax != null : !this$totalTax.equals(other$totalTax))
      return false;
    final java.lang.Object this$shippingCost = this.shippingCost;
    final java.lang.Object other$shippingCost = other.shippingCost;
    if (this$shippingCost == null
        ? other$shippingCost != null
        : !this$shippingCost.equals(other$shippingCost)) return false;
    return true;
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public int hashCode() {
    final int PRIME = 59;
    int result = 1;
    result = result * PRIME + java.lang.Float.floatToIntBits(this.totalCost);
    final java.lang.Object $subtotal = this.subtotal;
    result = result * PRIME + ($subtotal == null ? 43 : $subtotal.hashCode());
    final java.lang.Object $totalTax = this.totalTax;
    result = result * PRIME + ($totalTax == null ? 43 : $totalTax.hashCode());
    final java.lang.Object $shippingCost = this.shippingCost;
    result = result * PRIME + ($shippingCost == null ? 43 : $shippingCost.hashCode());
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy