/** * Constructs a new object with key/value pairs from an array. * * @param pairs * An array containing pairs of RenderingHints keys and values */ public Hints(final RenderingHints.Key key1, final Object value1, final Object[] pairs) { this(fromPairs(key1, value1, pairs)); }
/** * Constructs a new object from key/value pair. * <p> * This method is intended for use with Java5: * <code>new Hints( Hints.BUFFER_LIMIT,1,Hints.BUFFER_POLICY,"weak" )</code> * * @param pairs * Key value pairs */ public Hints(final RenderingHints.Key key1, final Object value1, final RenderingHints.Key key2, final Object value2, Object[] pairs) { this(fromPairs(key1, value1, key2, value2, pairs)); }
/** * Constructs a new object with two key/value pair. * * @param key1 The key for the first pair * @param value1 The value for the first pair * @param key2 The key2 for the second pair * @param value2 The value2 for the second pair */ public Hints(final RenderingHints.Key key1, final Object value1, final RenderingHints.Key key2, final Object value2) { this( fromPairs( new Object[]{ key1, value1, key2, value2 } ) ); }
/** * Constructs a new object from key/value pair. * * @param key1 The key for the first pair. * @param value1 The value for the first pair. * @param key2 The key2 for the second pair. * @param value2 The value2 for the second pair. * @param pairs Additional pairs of keys and values. * * @since 2.4 */ public Hints(final RenderingHints.Key key1, final Object value1, final RenderingHints.Key key2, final Object value2, final Object... pairs) { this(key1, value1, key2, value2); fromPairs(pairs); }
/** * Utility method used to organize pairs into a Map. * * @param pairs * An array of Key/Value pairs * @return Map<Key,Value> * @throws ClassCastException * if Key/Value pairs do not match */ private static Map fromPairs(RenderingHints.Key key1, Object value1, Object[] pairs) { Map map = fromPairs(pairs); map.put(key1, value1); return map; }
/** * Constructs a new object with key/value pairs from an array. * * @param key1 The key for the first pair. * @param value1 The value for the first pair. * @param pairs An array containing additional pairs of keys and values. * * @since 2.4 * * @deprecated The {@code Object[]} argument was a kind of substitution for variable-length * arguments. In order to avoid confusion, it is safer to use the later. */ @Deprecated public Hints(final RenderingHints.Key key1, final Object value1, final Object[] pairs) { this(key1, value1); fromPairs(pairs); }
/** * Utility method used to organize pairs into a Map. * * @param pairs * An array of Key/Value pairs * @return Map<Key,Value> * @throws ClassCastException * if Key/Value pairs do not match */ private static Map fromPairs(RenderingHints.Key key1, Object value1, RenderingHints.Key key2, Object value2, Object[] pairs) { Map map = fromPairs(pairs); map.put(key1, value1); map.put(key2, value2); return map; }