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

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

/*
 *
 * 2020 Copyright (C) Geotab Inc. All rights reserved.
 */

package com.geotab.model.serialization;

import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import com.geotab.model.entity.failuremode.FailureMode;

public class ApiCustomSerializerModifier extends BeanSerializerModifier {

  @Override
  public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc,
      JsonSerializer serializer) {
    if (FailureMode.class.isAssignableFrom(beanDesc.getBeanClass())) {
      return new FailureModeSerializer((JsonSerializer) serializer);
    }
    return serializer;
  }
}