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

tech.jhipster.lite.shared.error.domain.NumberValueTooLowException Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package tech.jhipster.lite.shared.error.domain;

import java.util.Map;

public final class NumberValueTooLowException extends AssertionException {

  private final String min;
  private final String value;

  private NumberValueTooLowException(NumberValueTooLowExceptionBuilder builder) {
    super(builder.field, builder.message());
    min = builder.minValue;
    value = builder.value;
  }

  public static NumberValueTooLowExceptionBuilder builder() {
    return new NumberValueTooLowExceptionBuilder();
  }

  public static class NumberValueTooLowExceptionBuilder {

    private String field;
    private String minValue;
    private String value;

    public NumberValueTooLowExceptionBuilder field(String field) {
      this.field = field;

      return this;
    }

    public NumberValueTooLowExceptionBuilder minValue(String minValue) {
      this.minValue = minValue;

      return this;
    }

    public NumberValueTooLowExceptionBuilder value(String value) {
      this.value = value;

      return this;
    }

    public String message() {
      return new StringBuilder()
        .append("Value of field \"")
        .append(field)
        .append("\" must be at least ")
        .append(minValue)
        .append(" but was ")
        .append(value)
        .toString();
    }

    public NumberValueTooLowException build() {
      return new NumberValueTooLowException(this);
    }
  }

  @Override
  public AssertionErrorType type() {
    return AssertionErrorType.NUMBER_VALUE_TOO_LOW;
  }

  @Override
  public Map parameters() {
    return Map.of("min", min, "value", value);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy