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

com.stripe.model.ExpandableFieldSerializer Maven / Gradle / Ivy

There is a newer version: 28.1.0-beta.3
Show newest version
package com.stripe.model;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;

public class ExpandableFieldSerializer implements JsonSerializer> {
  /** Serializes an expandable attribute into a JSON string. */
  @Override
  public JsonElement serialize(
      ExpandableField src, Type typeOfSrc, JsonSerializationContext context) {
    if (src.isExpanded()) {
      return context.serialize(src.getExpanded());
    } else if (src.getId() != null) {
      return new JsonPrimitive(src.getId());
    } else {
      return null;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy