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

io.github.mmm.validation.number.NumberValidatorBuilder Maven / Gradle / Ivy

The newest version!
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0 */
package io.github.mmm.validation.number;

import io.github.mmm.base.range.NumberRangeType;
import io.github.mmm.validation.AbstractValidator;
import io.github.mmm.validation.main.ComparableValidatorBuilder;

/**
 * {@link ComparableValidatorBuilder Validator builder} for {@link Number} values.
 *
 * @param  the generic type of the value to {@link AbstractValidator#validate(Object) validate}.
 * @param  the generic type of the {@link #and() parent builder}.
 * @param  the generic type of this builder itself (this).
 *
 * @since 1.0.0
 */
public abstract class NumberValidatorBuilder, PARENT, SELF extends ComparableValidatorBuilder>
    extends ComparableValidatorBuilder {

  /**
   * The constructor.
   *
   * @param parent the {@link #and() parent} builder.
   */
  public NumberValidatorBuilder(PARENT parent) {

    super(parent);
  }

  @Override
  public SELF range(String min, String max) {

    V vMin = null;
    if (min != null) {
      vMin = parse(min);
    }
    V vMax = null;
    if (max != null) {
      vMax = parse(max);
    }
    range(vMin, vMax);
    return self();
  }

  @Override
  public SELF range(V min, V max) {

    if ((min != null) || (max != null)) {
      return range(new NumberRangeType<>(min, max));
    }
    return self();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy