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

com.github.dakusui.crest.matcherbuilders.AsList Maven / Gradle / Ivy

package com.github.dakusui.crest.matcherbuilders;

import com.github.dakusui.crest.core.Printable;
import com.github.dakusui.crest.functions.CrestPredicates;

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

public class AsList extends AsObject, AsList> {
  public AsList(Function> function) {
    super(function);
  }

  public AsList containsAll(Collection collection) {
    return this.check(CrestPredicates.containsAll(collection));
  }

  public AsList containsOnly(Collection collection) {
    return this.check(CrestPredicates.containsOnly(collection));
  }

  public AsList containsExactly(Collection collection) {
    return this.check(CrestPredicates.containsExactly(collection));
  }

  public AsList contains(Object entry) {
    return this.check(CrestPredicates.contains(entry));
  }

  public AsList isEmpty() {
    return this.check(CrestPredicates.isEmpty());
  }

  public AsList allMatch(Predicate predicate) {
    return this.check(
        Printable.predicate(
            String.format("allMatch[%s]", predicate),
            entries -> entries.stream().allMatch(predicate)
        ));
  }

  public AsList anyMatch(Predicate predicate) {
    return this.check(
        Printable.predicate(
            String.format("anyMatch[%s]", predicate),
            entries -> entries.stream().anyMatch(predicate)
        ));
  }

  public AsList noneMatch(Predicate predicate) {
    return this.check(
        Printable.predicate(
            String.format("noneMatch[%s]", predicate),
            entries -> entries.stream().noneMatch(predicate)
        ));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy