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

io.leonis.subra.ipc.serialization.gson.FieldArcSerializer Maven / Gradle / Ivy

There is a newer version: 0.0.8
Show newest version
package io.leonis.subra.ipc.serialization.gson;

import com.google.gson.*;
import java.lang.reflect.Type;
import io.leonis.subra.game.data.FieldArc;

/**
 * Class for handling serialization of FieldArc objects.
 *
 * @author Ryan Meulenkamp
 */
public final class FieldArcSerializer implements JsonSerializer {
  @Override
  public JsonElement serialize(
      final FieldArc field,
      final Type type,
      final JsonSerializationContext context
  ) {
    final JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("x", field.getX());
    jsonObject.addProperty("y", field.getY());
    jsonObject.addProperty("startAngle", field.getStartAngle());
    jsonObject.addProperty("stopAngle", field.getStopAngle());
    jsonObject.addProperty("thickness", field.getThickness());
    jsonObject.addProperty("radius", field.getRadius());
    return jsonObject;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy