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

com.dslplatform.json.runtime.OptionalDecoder Maven / Gradle / Ivy

There is a newer version: 1.10.0
Show newest version
package com.dslplatform.json.runtime;

import com.dslplatform.json.JsonReader;

import java.io.IOException;
import java.util.Optional;

public final class OptionalDecoder implements JsonReader.ReadObject> {

	private final JsonReader.ReadObject decoder;

	public OptionalDecoder(final JsonReader.ReadObject decoder) {
		if (decoder == null) throw new IllegalArgumentException("decoder can't be null");
		this.decoder = decoder;
	}

	@Override
	public Optional read(JsonReader reader) throws IOException {
		if (reader.wasNull()) return Optional.empty();
		return Optional.ofNullable(decoder.read(reader));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy