package org.opencode4workspace.json;

import java.lang.reflect.Type;

import org.opencode4workspace.authentication.AppToken.TokenType;
import org.opencode4workspace.bo.Person.PresenceStatus;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

/**
 * Deserialiser to convert String token type to Enum
 * 
 * @author Christian Guedemann
 * 
 * @since 0.5.0
 *
 */
public class PersonPresenceDeserializer implements JsonDeserializer<PresenceStatus> {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type, com.google.gson.JsonDeserializationContext)
	 */
	@Override
	public PresenceStatus deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
		PresenceStatus[] presenceStatuses = PresenceStatus.values();
		for (PresenceStatus presenceStatus : presenceStatuses) {
			if (presenceStatus.getLabel().equals(json.getAsString())) {
				return presenceStatus;
			}
		}
		return null;
	}

}

@@ -399,18 +399,32 @@
 ing 
-token type
+PresenceStatus in Person
  to 
@@ -447,27 +447,20 @@
 hor 
-Christian Guedemann
+Paul Withers
 %0A * 
@@ -476,9 +476,9 @@
 e 0.
-5
+7
 .0%0A 

Comment not updated