Class FormatUtils


  • public final class FormatUtils
    extends Object
    Utilities for formatting property values
    Author:
    bas.rutten
    • Method Detail

      • extractAndFormat

        public static <T> String extractAndFormat​(EntityModelFactory entityModelFactory,
                                                  MessageService messageService,
                                                  AttributeModel am,
                                                  Object obj,
                                                  Locale locale,
                                                  String currencySymbol)
        Extracts a field value from an object and formats it
        Parameters:
        am - the attribute model
        obj - the object from which to extract the value
        local - the locale
        currencySymbol - the currency symbol
        Returns:
      • formatEntity

        public static String formatEntity​(EntityModel<?> entityModel,
                                          Object value)
        Formats and entity
        Parameters:
        entityModel - the entity model for the entity
        value - the entity
        Returns:
      • formatEntityCollection

        public static String formatEntityCollection​(EntityModelFactory entityModelFactory,
                                                    AttributeModel attributeModel,
                                                    Object collection,
                                                    String separator,
                                                    Locale locale,
                                                    String currencySymbol)
        Formats a collection of entities (turns it into a comma-separated string based on the value of the "displayProperty")
        Parameters:
        entityModelFactory - the entity model factory
        collection - the collection of entities to format
        Returns:
      • formatPropertyValue

        public static <T> String formatPropertyValue​(EntityModelFactory entityModelFactory,
                                                     MessageService messageService,
                                                     AttributeModel model,
                                                     Object value,
                                                     String separator,
                                                     Locale locale,
                                                     String currencySymbol)
        Formats a property value
        Parameters:
        entityModelFactory - the entity model factory
        entityModel - the entity model
        model - the attribute model
        value - the property value
        locale - the locale to use
        Returns: