Class MetadataHelper


  • public class MetadataHelper
    extends Object

    Purpose: Define any useful static methods to manipulate with descriptors content.

    • Method Detail

      • buildColsFromMappings

        public static void buildColsFromMappings​(StringBuilder target,
                                                 Collection<? extends MetadataAccessor> mappings,
                                                 String separator)
        Append list of columns from descriptor class to provided StringBuilder. Use to create content of columns brackets in INSERT INTO table (col1, col1) VALUES ....
        Parameters:
        target - Target StringBuilder.
        mappings - Object attributes mappings.
        separator - String to separate values in list.
      • buildValuesAsQMarksFromMappings

        public static void buildValuesAsQMarksFromMappings​(StringBuilder target,
                                                           Collection<? extends MetadataAccessor> mappings,
                                                           String separator)
        Append list of values as list of question marks from descriptor class to provided StringBuilder. Use to create content of VALUES brackets in INSERT INTO table ... VALUES (?, ?) ....
        Parameters:
        target - Target StringBuilder.
        mappings - Object attributes mappings.
        separator - String to separate values in list.
      • buildColsAndValuesBindingsFromMappings

        public static void buildColsAndValuesBindingsFromMappings​(StringBuilder target,
                                                                  Collection<? extends MetadataAccessor> mappings,
                                                                  int valueIndex,
                                                                  String binder,
                                                                  String separator)
        Append list of column to value bindings from descriptor class to provided StringBuilder. Use to create value to column bindings of SET content in UPDATE table SET col1 = ?2 WHERE ...
        Parameters:
        target - Target StringBuilder.
        mappings - Object attributes mappings.
        valueIndex - First value index in column to value bindings (e.g. column = ?>valueIndex>).
        binder - String to bind value to column (e.g. " = " in column = ?>valueIndex>).
        separator - String to separate values in list.