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

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

package com.geotab.model.serialization.serdes;

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 o, JsonGenerator jg, SerializerProvider sp) throws IOException {
    if (o.isSystemEntity()) {
      jg.writeString(o.getId().getId());
    } else {
      jg.writeString(UNIT_OF_MEASURE_NONE_ID);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy