Class Conditions


  • public class Conditions
    extends Object
    Common conditions for architecture tests.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends com.tngtech.archunit.core.domain.properties.HasName>
      com.tngtech.archunit.lang.ArchCondition<T>
      fulfill​(com.tngtech.archunit.base.DescribedPredicate<T> predicate)
      Generic condition to check fulfillment of a predicate.
      static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafArgumentTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
      Tests leaf argument types of a method against the given predicate.
      static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafExceptionTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
      Tests leaf exception types of a method against the given predicate.
      static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafReturnTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
      Tests leaf return types of a method against the given predicate.
      static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
      Tests leaf types of a method against the given predicate.
    • Method Detail

      • fulfill

        public static <T extends com.tngtech.archunit.core.domain.properties.HasName> com.tngtech.archunit.lang.ArchCondition<T> fulfill​(com.tngtech.archunit.base.DescribedPredicate<T> predicate)
        Generic condition to check fulfillment of a predicate.
      • haveLeafTypes

        public static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
        Tests leaf types of a method against the given predicate.

        Given some JavaType, "leaf" types are recursively determined as described below. Leaf types are taken from argument, return, and (declared) exception types.

        • If the type is an array type, check its base component type.
        • If the type is a generic type, check the type itself and all of its type arguments.
        • Otherwise, check just the type itself.
      • haveLeafReturnTypes

        public static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafReturnTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
        Tests leaf return types of a method against the given predicate.

        See haveLeafTypes(DescribedPredicate) for details.

      • haveLeafArgumentTypes

        public static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafArgumentTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
        Tests leaf argument types of a method against the given predicate.

        See haveLeafTypes(DescribedPredicate) for details.

      • haveLeafExceptionTypes

        public static com.tngtech.archunit.lang.ArchCondition<com.tngtech.archunit.core.domain.JavaMethod> haveLeafExceptionTypes​(com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> typePredicate)
        Tests leaf exception types of a method against the given predicate.

        See haveLeafTypes(DescribedPredicate) for details.