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 optReader;

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy