Class MapTupleBuilder


  • public class MapTupleBuilder
    extends Object
    A builder for MapTuple objects.

    These are objects that function as tuples, allowing access by either index or by key. To use this class, construct a new instance at the top of your operation, such as:

    MapTupleBuilder mtb = new MapTupleBuilder(“identity”, “accountName”, “date”);

    Then, for each item, such as from a ResultSet, do this:

    MapTuple tuple = mtb.of(resultSet.getString(“identity”), resultSet.getString(“name”), resultSet.getDate(“created”));

    In this example, the value for ‘identity’ can be accessed any of these ways:

    tuple.get(“identity”); tuple.getAt(0); tuple.getFirst();

    • Method Detail

      • withKeys

        public static MapTupleBuilder withKeys​(String... keys)
        Constructs a new MapTupleBuilder with the keys in the list.
        Parameters:
        keys - At least one key to use in the resulting tuples
        Returns:
        A builder with the given keys
      • withKeys

        public static MapTupleBuilder withKeys​(List<String> keys)
        Constructs a new MapTupleBuilder with the keys in the list.
        Parameters:
        keys - A list containing at least one non-null key to use the resulting tuples
        Returns:
        A builder with the given keys
      • of

        public MapTuple of​(Object... values)
        Constructs a MapTuple pairing this builder’s keys with the given values, both in order.

        The number of values must match the number of keys.

        Parameters:
        values - The values to add
        Returns:
        The resulting map
      • ofList

        public MapTuple ofList​(List<Object> values)
        Constructs a MapTuple pairing this builder’s keys with the given values, both in order.

        The number of values must match the number of keys.

        Parameters:
        values - The values to add
        Returns:
        The resulting map