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

net.sourceforge.plantuml.project.Failable Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.project;

public class Failable {

	private final O data;
	private final String error;

	public static  Failable ok(O data) {
		return new Failable<>(data, null);
	}

	public static  Failable error(String error) {
		return new Failable<>(null, error);
	}

	private Failable(O data, String error) {
		if (data == null && error == null) {
			throw new IllegalArgumentException();
		}
		if (data != null && error != null) {
			throw new IllegalArgumentException();
		}
		this.data = data;
		this.error = error;
	}

	public O get() {
		if (data == null) {
			throw new IllegalStateException();
		}
		return data;
	}

	public boolean isFail() {
		return data == null;
	}

	public String getError() {
		if (error == null) {
			throw new IllegalStateException();
		}
		return error;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy