All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.podio.contact.ProfileFieldValues Maven / Gradle / Ivy

package com.podio.contact;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonValue;

public final class ProfileFieldValues {

	private Map, Object> values = new HashMap, Object>();

	@JsonValue
	public Map, Object> getValues() {
		return values;
	}

	public void setValues(Map, Object> values) {
		this.values = values;
	}

	public  void setValue(ProfileField field, F value) {
		if (field.isSingle()) {
			values.put(field, value);
		} else {
			values.put(field, Collections.singletonList(value));
		}
	}

	public  F getValue(ProfileField field) {
		if (field.isSingle()) {
			return (F) values.get(field);
		} else {
			List list = (List) values.get(field);
			if (list == null || list.isEmpty()) {
				return null;
			}

			return (F) list.get(0);
		}
	}

	public  void setValues(ProfileField field, List values) {
		this.values.put(field, values);
	}

	public  List getValues(ProfileField field) {
		return (List) values.get(field);
	}
}