Class Accountables


  • public class Accountables
    extends java.lang.Object
    Helper methods for constructing nested resource descriptions and debugging RAM usage.

    toString(Accountable} can be used to quickly debug the nested structure of any Accountable.

    The namedAccountable and namedAccountables methods return type-safe, point-in-time snapshots of the provided resources.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Accountables()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Accountable namedAccountable​(java.lang.String description, long bytes)
      Returns an accountable with the provided description and bytes.
      static Accountable namedAccountable​(java.lang.String description, java.util.Collection<Accountable> children, long bytes)
      Returns an accountable with the provided description, children and bytes.
      static Accountable namedAccountable​(java.lang.String description, Accountable in)
      Augments an existing accountable with the provided description.
      static java.util.Collection<Accountable> namedAccountables​(java.lang.String prefix, java.util.Map<?,​? extends Accountable> in)
      Converts a map of resources to a collection.
      private static java.lang.StringBuilder toString​(java.lang.StringBuilder dest, Accountable a, int depth)  
      static java.lang.String toString​(Accountable a)
      Returns a String description of an Accountable and any nested resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Accountables

        private Accountables()
    • Method Detail

      • toString

        public static java.lang.String toString​(Accountable a)
        Returns a String description of an Accountable and any nested resources. This is intended for development and debugging.
      • toString

        private static java.lang.StringBuilder toString​(java.lang.StringBuilder dest,
                                                        Accountable a,
                                                        int depth)
      • namedAccountable

        public static Accountable namedAccountable​(java.lang.String description,
                                                   Accountable in)
        Augments an existing accountable with the provided description.

        The resource description is constructed in this format: description [toString()]

        This is a point-in-time type safe view: consumers will not be able to cast or manipulate the resource in any way.

      • namedAccountable

        public static Accountable namedAccountable​(java.lang.String description,
                                                   long bytes)
        Returns an accountable with the provided description and bytes.
      • namedAccountables

        public static java.util.Collection<Accountable> namedAccountables​(java.lang.String prefix,
                                                                          java.util.Map<?,​? extends Accountable> in)
        Converts a map of resources to a collection.

        The resource descriptions are constructed in this format: prefix 'key' [toString()]

        This is a point-in-time type safe view: consumers will not be able to cast or manipulate the resources in any way.

      • namedAccountable

        public static Accountable namedAccountable​(java.lang.String description,
                                                   java.util.Collection<Accountable> children,
                                                   long bytes)
        Returns an accountable with the provided description, children and bytes.

        The resource descriptions are constructed in this format: description [toString()]

        This is a point-in-time type safe view: consumers will not be able to cast or manipulate the resources in any way, provided that the passed in children Accountables (and all their descendants) were created with one of the namedAccountable functions.