Class SCMTrait<T extends SCMTrait<T>>

    • Constructor Detail

      • SCMTrait

        public SCMTrait()
    • Method Detail

      • asSetList

        @NonNull
        public static <T extends SCMTrait<?>> ArrayList<T> asSetList​(@CheckForNull
                                                                     Iterable<? extends T> list)
        Converts the supplied list of SCMTrait instances into a list where there is at most one instance of each trait.
        Type Parameters:
        T - type of SCMTrait.
        Parameters:
        list - the list to apply the constraint to.
        Returns:
        a new list that contains the first instance of any type of trait in the supplied list.
        Since:
        2.2.0
      • asSetList

        public static <T extends SCMTrait<?>> ArrayList<T> asSetList​(@NonNull
                                                                     T first,
                                                                     @CheckForNull
                                                                     Iterable<? extends T> list)
        Converts the supplied instance and list of SCMTrait instances into a list where there is at most one instance of each trait.
        Type Parameters:
        T - type of SCMTrait.
        Parameters:
        first - an entry to prepend to the list (will displace any duplicates in the list)
        list - the list to apply the constraint to.
        Returns:
        a new list that contains the first instance of any type of trait in the supplied list.
        Since:
        2.2.0
      • find

        @CheckForNull
        public static <T extends SCMTrait<?>> T find​(@NonNull
                                                     Iterable<?> traits,
                                                     @NonNull
                                                     Class<T> clazz)
        Finds the trait of the required type.
        Type Parameters:
        T - the type of trait.
        Parameters:
        traits - the traits to search.
        clazz - the type of trait.
        Returns:
        the matching trait from the supplied traits or null if there is no matching trait.
        Since:
        2.2.0