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

net.sf.mmm.util.validation.base.ValidatorDatePast Maven / Gradle / Ivy

There is a newer version: 8.7.0
Show 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 net.sf.mmm.util.validation.base;

import java.util.Date;

import net.sf.mmm.util.nls.api.NlsMessage;
import net.sf.mmm.util.validation.NlsBundleUtilValidationRoot;

/**
 * This is a {@link net.sf.mmm.util.validation.api.ValueValidator} that
 * {@link net.sf.mmm.util.validation.api.ValueValidator#validate(Object, Object) validates that a date} lies in the
 * past.
 *
 * @author Joerg Hohwiller (hohwille at users.sourceforge.net)
 * @since 3.1.0
 */
public class ValidatorDatePast extends AbstractValueValidator {

  /** @see #getCode() */
  public static final String CODE = "Past";

  /**
   * The constructor.
   */
  public ValidatorDatePast() {

    super();
  }

  @Override
  protected String getCode() {

    return CODE;
  }

  @Override
  protected NlsMessage validateNotNull(Date value) {

    if (value.before(new Date())) {
      return null;
    }
    return createBundle(NlsBundleUtilValidationRoot.class).errorValueNotInPast(value);
  }

  @Override
  public int hashCode() {

    return CODE.hashCode();
  }

  @Override
  public boolean equals(Object obj) {

    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    return true;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy