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

com.github.dakusui.pcond.provider.AssertionProvider Maven / Gradle / Ivy

package com.github.dakusui.pcond.provider;

import com.github.dakusui.pcond.internals.InternalUtils;
import com.github.dakusui.pcond.provider.impls.DefaultAssertionProvider;

import java.util.Properties;
import java.util.function.Predicate;

public interface AssertionProvider {
  AssertionProvider INSTANCE = createAssertionProvider(System.getProperties());

  static AssertionProvider createAssertionProvider(Properties properties) {
    String propertyKeyName = AssertionProvider.class.getCanonicalName();
    if (properties.containsKey(propertyKeyName)) {
      return InternalUtils.createInstanceFromClassName(AssertionProvider.class, properties.getProperty(propertyKeyName));
    }
    return new DefaultAssertionProvider();
  }

   T requireNonNull(T value);

   T requireArgument(T value, Predicate cond);

   T requireState(T value, Predicate cond);

   T require(T value, Predicate cond);

   T validate(T value, Predicate cond) throws AE;

   T ensureNonNull(T value);

   T ensureState(T value, Predicate cond);

   T ensure(T value, Predicate cond);

   boolean validation(T value, Predicate cond) throws AE;

   boolean that(T value, Predicate cond);

   boolean precondition(T value, Predicate cond);

   boolean postcondition(T value, Predicate cond);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy