net.sourceforge.plantuml.project.Failable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// 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;
}
}