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

com.geotab.model.serialization.ControllerAsStringSerializer Maven / Gradle / Ivy

package com.geotab.model.serialization;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.geotab.model.entity.controller.Controller;
import com.geotab.model.entity.controller.NoController;
import java.io.IOException;

public class ControllerAsStringSerializer extends JsonSerializer {

  @Override
  public void serialize(Controller controller, JsonGenerator jsonGenerator,
      SerializerProvider serializerProvider) throws IOException {
    if (NoController.getInstance().equals(controller)) {
      jsonGenerator.writeString(controller.getId().getId());
    } else {
      jsonGenerator.writeObject(controller.getId());
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy