/** * Applies a custom padding character to a given list of fields * * @param padding the padding to apply * @param names the names of the fields that should use the given padding character */ public void setPadding(char padding, String... names) { for (String name : names) { int position = indexOf(name); setPadding(position, padding); } }
/** * Applies alignment to a given list of fields * * @param alignment the alignment to apply * @param names the names of the fields that should be aligned */ public void setAlignment(FieldAlignment alignment, String... names) { for (String name : names) { int position = indexOf(name); setAlignment(position, alignment); } }
/** * Returns the alignment of a given field. An {@code IllegalArgumentException} will be thrown if no names have been defined. * * @param fieldName the name of the field whose alignment will be returned * * @return the alignment of the given field */ public FieldAlignment getAlignment(String fieldName) { int index = indexOf(fieldName); if (index == -1) { throw new IllegalArgumentException("Field '" + fieldName + "' does not exist. Available field names are: " + this.fieldNames); } return getAlignment(index); }