de.espirit.firstspirit.access.store.templatestore.gom.LanguageValueProviderExample


package de.espirit.firstspirit.access.store.templatestore.gom;

import de.espirit.firstspirit.access.Language;
import de.espirit.firstspirit.access.UserService;
import de.espirit.firstspirit.agency.LanguageAgent;
import de.espirit.firstspirit.agency.SpecialistsBroker;

import java.util.Map;
import org.jetbrains.annotations.NotNull;

import java.util.List;


/**
 * $Date: 2011-03-09 18:36:01 +0100 (Mi, 09. Mär 2011) $
 *
 * @version $Revision: 44040 $
 */
public class LanguageValueProviderExample implements GomIncludeValueProvider<Language>, Parameterizable {

	/**
	 * The generic gom-parameters. The field is not read in this example.
	 * @see #setParameters(java.util.Map)
	 */
	private Map<String, String> _parameters;


	@NotNull
	public Class<Language> getType() {
		return Language.class;
	}


	@Deprecated
	@NotNull
	public List<Language> getValues(@NotNull final UserService userService) {
		return userService.getProject().getLanguages();
	}


	@NotNull
	public List<Language> getValues(@NotNull final SpecialistsBroker broker) {
		return broker.requireSpecialist(LanguageAgent.TYPE).getLanguages();
	}


	@NotNull
	public String getKey(@NotNull final Language value) {
		return value.getAbbreviation();
	}


	/**
	 * Receives the generic gom-parameters. The parameters itself are not used in this example.
	 * @param parameters The key-mapped parameters.
	 */
	public void setParameters(@NotNull final Map<String, String> parameters) {
		_parameters = parameters;
	}

}