/** * Creates a tuple with a given value for <tt>first</tt> * * @param first defines the value to be used for the first component of the tuple * @param <F> defines the first type of the tuple * @param <S> defines the second type of the tuple * @return the newly created tuple */ public static <F, S> Tuple<F, S> create(F first) { return new Tuple<>(first, null); }
/** * Creates a new tuple with both values set to <tt>null</tt> * * @param <F> defines the first type of the tuple * @param <S> defines the second type of the tuple * @return the newly created tuple */ public static <F, S> Tuple<F, S> create() { return new Tuple<>(null, null); }
/** * Creates a tuple with a givens value for <tt>first</tt> and <tt>second</tt> * * @param first defines the value to be used for the first component of the tuple * @param second defines the value to be used for the second component of the tuple * @param <F> defines the first type of the tuple * @param <S> defines the second type of the tuple * @return the newly created tuple */ public static <F, S> Tuple<F, S> create(F first, S second) { return new Tuple<>(first, second); }
/** * Converts a map into a list of tuples. * * @param map the map to be converted * @param <K> the key type of the map and therefore the type of the first component of the tuples * @param <V> the value type of the map and therefore the type of the second component of the tuples * @return a list of tuples, containing one tuple per map entry where the first component is the key, * and the second component is the value of the map entry. */ public static <K, V> List<Tuple<K, V>> fromMap(@Nonnull Map<K, V> map) { List<Tuple<K, V>> result = new ArrayList<>(map.size()); for (Map.Entry<K, V> e : map.entrySet()) { result.add(new Tuple<>(e.getKey(), e.getValue())); } return result; }