Package com.massivecraft.factions.adapter

Source Code of com.massivecraft.factions.adapter.BoardAdapter

package com.massivecraft.factions.adapter;

import java.lang.reflect.Type;
import java.util.Map;

import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.xlib.gson.JsonDeserializationContext;
import com.massivecraft.mcore.xlib.gson.JsonDeserializer;
import com.massivecraft.mcore.xlib.gson.JsonElement;
import com.massivecraft.mcore.xlib.gson.JsonParseException;
import com.massivecraft.mcore.xlib.gson.JsonSerializationContext;
import com.massivecraft.mcore.xlib.gson.JsonSerializer;

import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.entity.Board;

public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Board>
{
  // -------------------------------------------- //
  // INSTANCE & CONSTRUCT
  // -------------------------------------------- //
 
  private static BoardAdapter i = new BoardAdapter();
  public static BoardAdapter get() { return i; }
 
  // -------------------------------------------- //
  // OVERRIDE
  // -------------------------------------------- //
 
  @SuppressWarnings("unchecked")
  @Override
  public Board deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
  {
    return new Board((Map<PS, TerritoryAccess>) context.deserialize(json, Board.MAP_TYPE));
  }

  @Override
  public JsonElement serialize(Board src, Type typeOfSrc, JsonSerializationContext context)
  {
    return context.serialize(src.getMap(), Board.MAP_TYPE);
  }
 
}
TOP

Related Classes of com.massivecraft.factions.adapter.BoardAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.