Class Attributes


  • public final class Attributes
    extends java.lang.Object
    Utility class providing Attribute related functions.
    • Method Detail

      • resolveAttributes

        public static <T extends Attribute> java.util.List<T> resolveAttributes​(java.util.List<Attribute> attributes,
                                                                                java.lang.Class<T> type)
        Resolves all attributes of a specific type.
        Type Parameters:
        T - the actual attribute type to resolve.
        Parameters:
        attributes - the attribute list to examine.
        type - the attribute type to resolve.
        Returns:
        the resolved list of attribute objects (may be empty).
      • resolveUniqueAttribute

        public static <T extends Attribute> T resolveUniqueAttribute​(java.util.List<Attribute> attributes,
                                                                     java.lang.Class<T> type)
                                                              throws java.io.IOException
        Resolves a unique attribute.
        Type Parameters:
        T - the actual attribute type to resolve.
        Parameters:
        attributes - the attribute list to examine.
        type - the attribute type to resolve.
        Returns:
        the resolved attribute instance.
        Throws:
        java.io.IOException - if the attribute does not exist or is not unique.
      • resolveOptionalAttribute

        public static <T extends Attribute> java.util.Optional<T> resolveOptionalAttribute​(java.util.List<Attribute> attributes,
                                                                                           java.lang.Class<T> type)
                                                                                    throws java.io.IOException
        Resolves an optional attribute.
        Type Parameters:
        T - the actual attribute type to resolve.
        Parameters:
        attributes - the attribute list to examine.
        type - the attribute type to resolve.
        Returns:
        the resolved attribute instance.
        Throws:
        java.io.IOException - if the attribute is not unique.
      • print

        public static void print​(java.util.List<? extends Attribute> attributes,
                                 ClassPrinter out,
                                 ClassContext context)
                          throws java.io.IOException
        Prints a list of attributes.
        Parameters:
        attributes - the attributes to print.
        out - the ClassPrinter to print to.
        context - the ClassContext to use for printing.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • print

        public static void print​(java.util.Optional<? extends Attribute> attribute,
                                 ClassPrinter out,
                                 ClassContext context)
                          throws java.io.IOException
        Prints an optional attributes.
        Parameters:
        attribute - the attributes to print.
        out - the ClassPrinter to print to.
        context - the ClassContext to use for printing.
        Throws:
        java.io.IOException - if an I/O error occurs.