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

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

package com.geotab.model.serialization;

import static com.geotab.model.entity.unitofmeasure.UnitOfMeasureNone.UNIT_OF_MEASURE_NONE_ID;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.geotab.model.entity.unitofmeasure.UnitOfMeasure;
import java.io.IOException;

public class UnitOfMeasureSerializer extends JsonSerializer {

  @Override
  public void serialize(UnitOfMeasure unitOfMeasure, JsonGenerator jsonGenerator,
      SerializerProvider serializerProvider) throws IOException {
    if (unitOfMeasure.isSystemEntity()) {
      jsonGenerator.writeString(unitOfMeasure.getId().getId());
    } else {
      jsonGenerator.writeString(UNIT_OF_MEASURE_NONE_ID);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy