Class FeatureUtil

java.lang.Object
com.google.common.collect.testing.features.FeatureUtil

public class FeatureUtil extends Object
Utilities for collecting and validating tester requirements from annotations.
  • Field Details

  • Constructor Details

    • FeatureUtil

      public FeatureUtil()
  • Method Details

    • addImpliedFeatures

      public static Set<Feature<?>> addImpliedFeatures(Set<Feature<?>> features)
      Given a set of features, add to it all the features directly or indirectly implied by any of them, and return it.
      Parameters:
      features - the set of features to expand
      Returns:
      the same set of features, expanded with all implied features
    • impliedFeatures

      public static Set<Feature<?>> impliedFeatures(Set<Feature<?>> features)
      Given a set of features, return a new set of all features directly or indirectly implied by any of them.
      Parameters:
      features - the set of features whose implications to find
      Returns:
      the implied set of features
    • getTesterRequirements

      public static TesterRequirements getTesterRequirements(Class<?> testerClass) throws ConflictingRequirementsException
      Get the full set of requirements for a tester class.
      Parameters:
      testerClass - a tester class
      Returns:
      all the constraints implicitly or explicitly required by the class or any of its superclasses.
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • getTesterRequirements

      public static TesterRequirements getTesterRequirements(Method testerMethod) throws ConflictingRequirementsException
      Get the full set of requirements for a tester class.
      Parameters:
      testerMethod - a test method of a tester class
      Returns:
      all the constraints implicitly or explicitly required by the method, its declaring class, or any of its superclasses.
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • buildTesterRequirements

      static TesterRequirements buildTesterRequirements(Class<?> testerClass) throws ConflictingRequirementsException
      Construct the full set of requirements for a tester class.
      Parameters:
      testerClass - a tester class
      Returns:
      all the constraints implicitly or explicitly required by the class or any of its superclasses.
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • buildTesterRequirements

      static TesterRequirements buildTesterRequirements(Method testerMethod) throws ConflictingRequirementsException
      Construct the full set of requirements for a tester method.
      Parameters:
      testerMethod - a test method of a tester class
      Returns:
      all the constraints implicitly or explicitly required by the method, its declaring class, or any of its superclasses.
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • buildTesterRequirements

      private static TesterRequirements buildTesterRequirements(Annotation testerAnnotation) throws ConflictingRequirementsException
      Find all the constraints explicitly or implicitly specified by a single tester annotation.
      Parameters:
      testerAnnotation - a tester annotation
      Returns:
      the requirements specified by the annotation
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • buildDeclaredTesterRequirements

      public static TesterRequirements buildDeclaredTesterRequirements(AnnotatedElement classOrMethod) throws ConflictingRequirementsException
      Construct the set of requirements specified by annotations directly on a tester class or method.
      Parameters:
      classOrMethod - a tester class or a test method thereof
      Returns:
      all the constraints implicitly or explicitly required by annotations on the class or method.
      Throws:
      ConflictingRequirementsException - if the requirements are mutually inconsistent.
    • getTesterAnnotations

      public static Iterable<Annotation> getTesterAnnotations(AnnotatedElement classOrMethod)
      Find all the tester annotations declared on a tester class or method.
      Parameters:
      classOrMethod - a class or method whose tester annotations to find
      Returns:
      an iterable sequence of tester annotations on the class
    • incorporateRequirements

      private static TesterRequirements incorporateRequirements(TesterRequirements requirements, TesterRequirements moreRequirements, Object source) throws ConflictingRequirementsException
      Incorporate additional requirements into an existing requirements object.
      Parameters:
      requirements - the existing requirements object
      moreRequirements - more requirements to incorporate
      source - the source of the additional requirements (used only for error reporting)
      Returns:
      the existing requirements object, modified to include the additional requirements
      Throws:
      ConflictingRequirementsException - if the additional requirements are inconsistent with the existing requirements
    • checkConflict

      private static void checkConflict(String earlierRequirement, Set<Feature<?>> earlierFeatures, String newRequirement, Set<Feature<?>> newFeatures, Object source) throws ConflictingRequirementsException
      Throws:
      ConflictingRequirementsException
    • intersection

      public static <T> Set<T> intersection(Set<? extends T> set1, Set<? extends T> set2)
      Construct a new Set that is the intersection of the given sets.