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

com.plaid.client.internal.gson.RequiredField Maven / Gradle / Ivy

package com.plaid.client.internal.gson;

/**
 * Simple wrapper class for JSON fields that must always
 * be present in serialized output (that is, if not present,
 * null must always be emitted as its value).
 * 

* Basically the same thing as Optional which is in Java 1.8, * but we reimplement our own to support lower java versions. * * @param the type being wrapped */ public final class RequiredField { private final T value; private static final RequiredField EMPTY = new RequiredField<>(null); private RequiredField(T value) { this.value = value; } @SuppressWarnings("unchecked") public static RequiredField empty() { return (RequiredField) EMPTY; } public static RequiredField of(S value) { return new RequiredField(value); } public boolean isPresent() { return value != null; } public T get() { return value; } }