OrderedProperties { public OrderedProperties addIterablePairs(Iterable<? extends Map.Entry<String, ?>> iterable) { for (Map.Entry<String, ?> entry : iterable) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof String) { pairs.put(key, (String) value); } else if (value instanceof Integer || value instanceof Long || value instanceof Boolean || value instanceof Double || value instanceof Float) { pairs.put(key, String.valueOf(value)); } else if (value == null) { throw new InvalidConfigParameterException(key, "A null value is not allowed for this key"); } else { throw new InvalidConfigParameterException(key, " - Unsupported type " + value.getClass() + " in configuration for this key"); } } return this; }  OrderedProperties filter(Predicate<String> filter); OrderedProperties addMapPairs(Map<String, String> additionalPairs); OrderedProperties addIterablePairs(Iterable<? extends Map.Entry<String, ?>> iterable); OrderedProperties addStringPairs(String keyValuePairs); OrderedProperties addStringPairs(InputStream is); OrderedProperties addPair(String key, String value); String asPairs(); String asPairsWithComment(String comment); Map<String, String> asMap(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void addIterablePairs() { Map<String, Object> additional = new LinkedHashMap<>(); additional.put("fifth", 5); additional.put("first", 6L); additional.put("second", true); additional.put("third", 2.3); additional.put("FOURTH", 4.6D); OrderedProperties pairs = createTestKeyValues().addIterablePairs(additional.entrySet()); assertKeyOrder(pairs, "first", "second", "third", "FOURTH", "fifth"); assertValueOrder(pairs, "6", "true", "2.3", "4.6", "5"); }