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

com.helger.phive.api.validity.IValidityDeterminator Maven / Gradle / Ivy

/*
 * Copyright (C) 2014-2024 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.helger.phive.api.validity;

import javax.annotation.Nonnull;

import com.helger.commons.error.list.IErrorList;
import com.helger.phive.api.executor.IValidationExecutor;
import com.helger.phive.api.source.IValidationSource;

/**
 * Generic interface for a decision provider for validation results.
 *
 * @author Philip Helger
 * @since 10.0.0
 * @param 
 *        The validation source type to use.
 */
public interface IValidityDeterminator 
{
  /**
   * Get the validity of the provided error list.
   *
   * @param aExecutor
   *        The validation executor for which the validity state should be
   *        determined. This gives access to the underlying rule resource and
   *        the respective validation type. Never null.
   * @param aErrorList
   *        The error list to be evaluated. May not be null but
   *        empty.
   * @return Never null.
   */
  @Nonnull
  EExtendedValidity getValidity (@Nonnull IValidationExecutor  aExecutor, @Nonnull IErrorList aErrorList);

  /**
   * @return A validity determinator that marks entries with at least one error
   *         as INVALID and others as VALID. It contains no uncertainty.
   */
  static  IValidityDeterminator  createCertainOneErrorInvalid ()
  {
    return (ex, errList) -> errList.containsAtLeastOneError () ? EExtendedValidity.INVALID : EExtendedValidity.VALID;
  }

  /**
   * @return The default determinator. It's
   *         {@link #createCertainOneErrorInvalid()}
   */
  @Nonnull
  static  IValidityDeterminator  createDefault ()
  {
    return createCertainOneErrorInvalid ();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy