Search in sources :

Example 1 with SpreadMapEvaluatingException

use of groovy.lang.SpreadMapEvaluatingException in project groovy by apache.

the class InvokerHelper method spreadMap.

public static SpreadMap spreadMap(Object value) {
    if (value instanceof Map) {
        Object[] values = new Object[((Map) value).keySet().size() * 2];
        int index = 0;
        for (Object key : ((Map) value).keySet()) {
            values[index++] = key;
            values[index++] = ((Map) value).get(key);
        }
        return new SpreadMap(values);
    }
    throw new SpreadMapEvaluatingException("Cannot spread the map " + typeName(value) + ", value " + value);
}
Also used : SpreadMap(groovy.lang.SpreadMap) SpreadMapEvaluatingException(groovy.lang.SpreadMapEvaluatingException) GroovyObject(groovy.lang.GroovyObject) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) SpreadMap(groovy.lang.SpreadMap)

Aggregations

GroovyObject (groovy.lang.GroovyObject)1 SpreadMap (groovy.lang.SpreadMap)1 SpreadMapEvaluatingException (groovy.lang.SpreadMapEvaluatingException)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1