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

com.evrythng.thng.resource.model.store.SocialNetwork Maven / Gradle / Ivy

There is a newer version: 1.33
Show newest version
/*
 * (c) Copyright 2012 EVRYTHNG Ltd London / Zurich
 * www.evrythng.com
 */
package com.evrythng.thng.resource.model.store;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

public enum SocialNetwork {
	FACEBOOK("facebook", "fb"), EVRYONE("evryone", "evo");
	private static final Map serNames = new HashMap<>();
	private static final Map prefixes = new HashMap<>();
	private final String serName;
	private final String prefix;

	SocialNetwork(final String serName, final String prefix) {

		this.serName = serName;
		this.prefix = prefix;
	}

	static {
		for (SocialNetwork t : values()) {
			serNames.put(t.serName, t);
			prefixes.put(t.prefix, t);
		}
	}

	@JsonValue
	public String toString() {

		return serName;
	}

	@JsonCreator
	public static SocialNetwork fromString(final String serName) {

		if (serName == null) {
			return null;
		}
		SocialNetwork t = serNames.get(serName);
		if (t == null) {
			throw new IllegalArgumentException("Invalid enum value.");
		}
		return t;
	}

	public String getPrefix() {

		return prefix;
	}

	public static SocialNetwork fromPrefix(final String prefix) {

		SocialNetwork t = prefixes.get(prefix);
		if (t == null) {
			throw new IllegalArgumentException("Invalid prefix.");
		}
		return t;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy