Map values to fields of the target object type.

@param values fields values
@return A populated instance of the target type.
@throws Exception if values cannot be mapped to target object fields
559628
public T mapObject(final Map<String, String> values) throws Exception {

        T result = createInstance();

        // for each field
        for (Map.Entry<String, String> entry : values.entrySet()) {

            String field = entry.getKey();
            //get field raw value
            String value = values.get(field);

            Method setter = setters.get(field);
            if (setter == null) {
                LOGGER.warn("No public setter found for field {}, this field will be set to null (if object type) or default value (if primitive type)", field);
                continue;
            }

            Class<?> type = setter.getParameterTypes()[0];
            TypeConverter<String, ?> typeConverter = typeConverters.get(type);
            if (typeConverter == null) {
                LOGGER.warn(
                        "Type conversion not supported for type {}, field {} will be set to null (if object type) or default value (if primitive type)",
                        type, field);
                continue;
            }

            if (value == null) {
                LOGGER.warn("Attempting to convert null to type {} for field {}, this field will be set to null (if object type) or default value (if primitive type)", type, field);
                continue;
            }

            if (value.isEmpty()) {
                LOGGER.debug("Attempting to convert an empty string to type {} for field {}, this field will be ignored", type, field);
                continue;
            }

            convertValue(result, field, value, setter, type, typeConverter);

        }

        return result;
    }
533062
public String[] buildWhereArgs(Collection<Object> values) {
		List<String> selectionArgs = new ArrayList<String>();
		for (Object value : values) {
			if (value != null) {
				selectionArgs.add(value.toString());
			}
		}
		return selectionArgs.isEmpty() ? null : selectionArgs
				.toArray(new String[] {});
	}
770928
private Object getObjectForString(Class<?> type, String values[]) throws Exception{
    if(values == null || values.length == 0)
      throw new Exception("getObjectForString: values was null or of zero length");
    Object array = Array.newInstance(type.getComponentType(), values.length);
    // Now fill in the values for the empty array we just created.
    for(int i = 0; i < values.length; i++)
      Array.set(array, i, getObjectForString(type, values[i]));
    return array;
  }
120594
public static AnyValueMap fromValue(Object value) {
		AnyValueMap result = new AnyValueMap();
		result.setAsObject(value);
		return result;
	}
1212549
public static Map<String, Object> convertValues(final Map<String, Object> data, final ConfigurationRequest configurationRequest) throws ValidationException {
        final Map<String, Object> configuration = Maps.newHashMapWithExpectedSize(data.size());
        final Map<String, Map<String, Object>> configurationFields = configurationRequest.asList();

        for (final Map.Entry<String, Object> entry : data.entrySet()) {
            final String field = entry.getKey();
            final Map<String, Object> fieldDescription = configurationFields.get(field);
            if (fieldDescription == null || fieldDescription.isEmpty()) {
                throw new ValidationException(field, "Unknown configuration field description for field \"" + field + "\"");
            }

            final String type = (String) fieldDescription.get("type");

            // Decide what to cast to. (string, bool, number)
            Object value;
            switch (type) {
                case "text":
                case "dropdown":
                    value = entry.getValue() == null ? "" : String.valueOf(entry.getValue());
                    break;
                case "number":
                    try {
                        value = Integer.parseInt(String.valueOf(entry.getValue()));
                    } catch (NumberFormatException e) {
                        // If a numeric field is optional and not provided, use null as value
                        if ("true".equals(String.valueOf(fieldDescription.get("is_optional")))) {
                            value = null;
                        } else {
                            throw new ValidationException(field, e.getMessage());
                        }
                    }
                    break;
                case "boolean":
                    value = "true".equalsIgnoreCase(String.valueOf(entry.getValue()));
                    break;
                case "list":
                    final List<?> valueList = entry.getValue() == null ? Collections.emptyList() : (List<?>) entry.getValue();
                    value = valueList.stream()
                            .filter(o -> o != null && o instanceof String)
                            .map(String::valueOf)
                            .collect(Collectors.toList());
                    break;
                default:
                    throw new ValidationException(field, "Unknown configuration field type \"" + type + "\"");
            }

            configuration.put(field, value);
        }

        return configuration;
    }
630275
protected Object[] cast(Collection values) {
        Object[] res = new Object[values.size()];
        int i = 0;
        for (Object value : values) {
            res[i++] = cast(value);
        }
        return res;
    }
1360860
private Map<Integer, Object> getFilter(List<PivotField> fields, List<Object> values) {
//		long start = System.currentTimeMillis();
		Map<Integer, Object> filter = new HashMap<Integer, Object>();
		for (int i = 0; i < values.size(); i++) {
			int fieldIndex = fields.get(i).getIndex();
			// System.out.println(fieldIndex);
			filter.put(fieldIndex, values.get(i));
		}
//		long stop = System.currentTimeMillis();
//		System.out.println("getFilter in " + (stop - start));
	
		return filter;
	}
774756
public <T> T getElValue(String keyEL, Object target, Object[] arguments, Class<T> valueType) throws Exception {
        return this.getElValue(keyEL, target, arguments, null, false, valueType);
    }
270735
public static Value.Builder makeValue(Iterable<Value> values) {
    return Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addAllValues(values));
  }
91621
public void extractValues(HashMap<String, String> values) {
        for (MultipleSyntaxElements l : childContainers) {
            l.extractValues(values);
        }
    }
369415
private void populate(Field field, Object target, String stringValue) {
        field.setAccessible(true);
        try {
            final Class fieldType = field.getType();
            final Object value = TypeConverter.convert(stringValue).to(fieldType);
            field.set(target, value);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Could not populate field " + field, e);
        }
    }
356036
private static void set(Field field, Object obj, String value) throws Exception {
        Class<?> clazz = field.getType();
        field.setAccessible(true);
        if (clazz.equals(Double.class) || clazz.equals(double.class)) {
            double val = Double.valueOf(value);
            field.set(obj, val);
        } else if (clazz.equals(String.class)) {
            field.set(obj, value);
        } else if (clazz.equals(Integer.class) || clazz.equals(int.class)) {
            int val = Integer.parseInt(value);
            field.set(obj, val);
        } else if (clazz.equals(Float.class) || clazz.equals(float.class)) {
            float f = Float.parseFloat(value);
            field.set(obj, f);
        }
    }
769755
public static void setFieldValeByType(Field field, Object obj, String value)
            throws Exception {

        Class<?> type = field.getType();

        String typeName = type.getName();

        if (typeName.equals("int")) {

            if (value.equals("")) {
                value = "0";
            }
            field.set(obj, Integer.valueOf(value));

        } else if (typeName.equals("long")) {

            if (value.equals("")) {
                value = "0";
            }
            field.set(obj, Long.valueOf(value));

        } else if (typeName.equals("boolean")) {

            if (value.equals("")) {
                value = "false";
            }
            field.set(obj, Boolean.valueOf(value));

        } else if (typeName.equals("double")) {

            if (value.equals("")) {
                value = "0.0";
            }
            field.set(obj, Double.valueOf(value));

        } else {

            field.set(obj, value);
        }
    }
402791
@Override
	public Collection<Object> values() {
		lock.readLock().lock();
		try {
			final List<Object> result = new LinkedList<Object>();
			final boolean useLocalPrefixes = !mixDefaultAndLocalPrefixes && hasLocalPrefixConfigurations();
			for (final Object key : getKeyMap(false).values()) {
				result.add(get(key, useLocalPrefixes));
			}
			return result;
		} finally {
			lock.readLock().unlock();
		}
	}
554638
public RepeatedFieldBuilder<MType, BType, IType> addAllMessages(
      final Iterable<? extends MType> values) {
    for (final MType value : values) {
      if (value == null) {
        throw new NullPointerException();
      }
    }
    if (values instanceof Collection) {
      @SuppressWarnings("unchecked")
      final Collection<MType> collection = (Collection<MType>) values;
      if (collection.size() == 0) {
        return this;
      }
      ensureMutableMessageList();
      for (final MType value : values) {
        addMessage(value);
      }
    } else {
      ensureMutableMessageList();
      for (final MType value : values) {
        addMessage(value);
      }
    }
    onChanged();
    incrementModCounts();
    return this;
  }
467764
private synchronized Collection<IInputValue> annotatedValuesToInputValues(Collection<IAnnotatedValue> values) throws ModelException
    {
        restartInputsMap();
        Collection<IInputValue> inputValues = new HashSet<IInputValue>();
        for (IAnnotatedValue annotatedValue : values)
        {
            IInput input = input(annotatedValue);
            if (null == input)
            {
                throw new ServiceExecutionException("Cannot find a suitable input for value: " + annotatedValue, null);
            }
            inputValues.add(addInputValue(input, annotatedValue));
        }
        return inputValues;
    }
660172
public PersistenceUnit<T> mappingFile(String ... values)
   {
      if (values != null)
      {
         for(String name: values)
         {
            childNode.createChild("mapping-file").text(name);
         }
      }
      return this;
   }