Enum FieldAlignment

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<FieldAlignment>

    public enum FieldAlignment
    extends java.lang.Enum<FieldAlignment>
    Alignment of text in a fixed-width field.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      CENTER
      Centralizes values
      LEFT
      Aligns values to the left
      RIGHT
      Aligns values to the right
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FieldAlignment()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int calculatePadding​(int totalLength, int lengthToWrite)
      Calculates how many whites paces to introduce before a value so it is printed as specified by the alignment type.
      static FieldAlignment valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static FieldAlignment[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • LEFT

        public static final FieldAlignment LEFT
        Aligns values to the left
      • CENTER

        public static final FieldAlignment CENTER
        Centralizes values
      • RIGHT

        public static final FieldAlignment RIGHT
        Aligns values to the right
    • Constructor Detail

      • FieldAlignment

        private FieldAlignment()
    • Method Detail

      • values

        public static FieldAlignment[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (FieldAlignment c : FieldAlignment.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static FieldAlignment valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • calculatePadding

        public int calculatePadding​(int totalLength,
                                    int lengthToWrite)
        Calculates how many whites paces to introduce before a value so it is printed as specified by the alignment type.
        Parameters:
        totalLength - the total length available to write for a given field
        lengthToWrite - the length of a value that will be written to the field
        Returns:
        the number of whites paces to introduce in before the value to make it align as specified.