public <X> KeyValue<X,B> setKey(final X key) { return new KeyValue<X,B>(key, this.value); }
public static <X> KeyValue<X,X> fromIterable(final Iterable<X> iterable) { return fromIterable(iterable, 0, true); }
/** * Resolves any dynamic content in the supplied key, value pair * * @param key a key, optionally containing dynamic content * @param value a value, optionally containing dynamic content * @param <K> * @param <V> * @return a tuple containing a copy of the {@code key} and {@code value} with dynamic content replaced */ private <K, V> KeyValue<K, V> resolveDynamicContent(K key, V value) { final K adaptedKey = resolveDynamicContentIfRequired(key); final V adaptedValue = resolveDynamicContentIfRequired(value); return KeyValue.with(adaptedKey, adaptedValue); }
/** * Replaces variables and functions inside a map with respective values and returns a new * map representation. * * @param map optionally having variable entries. * @return the constructed map without variable entries. */ public <T> Map<String, T> resolveDynamicValuesInMap(final Map<String, T> map) { Map<String, T> target = new LinkedHashMap<>(map.size()); for (Entry<String, T> entry : map.entrySet()) { final KeyValue<String, T> adaptedEntry = resolveDynamicContent(entry.getKey(), entry.getValue()); target.put(adaptedEntry.getKey(), adaptedEntry.getValue()); } return target; }
/** * Copies the passed {@code globalVariables} and adds them to the test context. * <br/>If any of the copied global variables contain dynamic content (references to other global variables or * functions) then this is resolved now. As a result it is important {@link #setFunctionRegistry(FunctionRegistry)} * is called first before calling this method. * * @param globalVariables */ public void setGlobalVariables(GlobalVariables globalVariables) { this.globalVariables = new GlobalVariables(); for (Entry<String, Object> entry : globalVariables.getVariables().entrySet()) { final KeyValue<String, Object> adaptedEntry = resolveDynamicContent(entry.getKey(), entry.getValue()); variables.put(adaptedEntry.getKey(), adaptedEntry.getValue()); this.globalVariables.getVariables().put(adaptedEntry.getKey(), adaptedEntry.getValue()); } }
public <X> KeyValue<X,B> setKey(final X key) { return new KeyValue<X,B>(key, this.value); }
public static <X> KeyValue<X,X> fromIterable(final Iterable<X> iterable, int index) { return fromIterable(iterable, index, false); }
public <Y> KeyValue<A,Y> setValue(final Y value) { return new KeyValue<A,Y>(this.key, value); }
public static <X> KeyValue<X,X> fromCollection(final Collection<X> collection) { return fromIterable(collection); }
public static <A,B> KeyValue<A,B> with(final A key, final B value) { return new KeyValue<A,B>(key,value); }
public static <X> KeyValue<X,X> fromCollection(final Collection<X> collection) { return fromIterable(collection); }
public static <A,B> KeyValue<A,B> with(final A key, final B value) { return new KeyValue<A,B>(key,value); }
public static <X> KeyValue<X,X> fromIterable(final Iterable<X> iterable, int index) { return fromIterable(iterable, index, false); }
public <Y> KeyValue<A,Y> setValue(final Y value) { return new KeyValue<A,Y>(this.key, value); }
public static <X> KeyValue<X,X> fromIterable(final Iterable<X> iterable) { return fromIterable(iterable, 0, true); }
/** * <p> * Create tuple from array. Array has to have exactly two elements. * </p> * * @param <X> the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static <X> KeyValue<X,X> fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 2) { throw new IllegalArgumentException("Array must have exactly 2 elements in order to create a KeyValue. Size is " + array.length); } return new KeyValue<X,X>(array[0],array[1]); }
/** * <p> * Create tuple from array. Array has to have exactly two elements. * </p> * * @param <X> the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static <X> KeyValue<X,X> fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 2) { throw new IllegalArgumentException("Array must have exactly 2 elements in order to create a KeyValue. Size is " + array.length); } return new KeyValue<X,X>(array[0],array[1]); }
public List<KeyValue<String, String>> getCookies() { if (cacheCookies != null) { return cacheCookies; } List<KeyValue<String, String>> ret = new ArrayList<>(); Cookie[] cookieArr = request.getCookies(); if (cookieArr != null) { for (Cookie acookie : cookieArr) { ret.add(new KeyValue<>(acookie.getName(), acookie.getValue())); } } cacheCookies = ret; return cacheCookies; }
return new KeyValue<X,X>(element0, element1);