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

com.github.dakusui.jcunit8.factorspace.TestPredicate Maven / Gradle / Ivy

The newest version!
package com.github.dakusui.jcunit8.factorspace;

import com.github.dakusui.jcunit.core.tuples.Tuple;
import com.github.dakusui.jcunit8.core.Utils;

import java.util.List;
import java.util.function.Predicate;

public interface TestPredicate extends Predicate {
  String getName();

  boolean test(Tuple tuple);

  List involvedKeys();

  static String toString(TestPredicate predicate) {
    return String.format(
        "%s:%s",
        Utils.className(predicate.getClass()), predicate.involvedKeys()
    );
  }

  static TestPredicate of(String name, List involvedKeys, Predicate predicate) {
    return new TestPredicate() {
      @Override
      public String getName() {
        return name;
      }

      @Override
      public boolean test(Tuple tuple) {
        return predicate.test(tuple);
      }

      @Override
      public List involvedKeys() {
        return involvedKeys;
      }
    };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy