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

io.github.mmm.validation.time.dayofweek.ValidatorBuilderDayOfWeek 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.time.dayofweek;

import java.time.DayOfWeek;
import java.util.Locale;

import io.github.mmm.validation.main.ComparableValidatorBuilder;

/**
 * {@link ComparableValidatorBuilder Validator builder} for {@link DayOfWeek}.
 *
 * @param  the generic type of the {@link #and() parent builder}.
 *
 * @since 1.0.0
 */
public class ValidatorBuilderDayOfWeek
    extends ComparableValidatorBuilder> {

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

    super(parent);
  }

  @Override
  protected DayOfWeek parse(String value) {

    if (value == null) {
      return null;
    }
    if (value.length() <= 1) {
      int m = Integer.parseInt(value);
      return DayOfWeek.of(m);
    } else {
      return DayOfWeek.valueOf(value.toUpperCase(Locale.ROOT));
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy