com.memority.toolkit.rule.api.LibraryInitializationOutcome Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toolkit-rule-api Show documentation
Show all versions of toolkit-rule-api Show documentation
This artifact provides the API classes that are necessary to implement the contracts of Memority configuration Rules.
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Toolkit API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.toolkit.rule.api;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
/**
* Describes the result of an {@link LibraryRule} execution.
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@EqualsAndHashCode
public class LibraryInitializationOutcome {
private Outcome outcome;
private String failureMessage;
public enum Outcome {
/**
* The Library initialized successfully
*/
SUCCESS,
/**
* The Library failed to initialize
*/
FAILURE,
}
@SuppressWarnings("unused")
// For Jackson
LibraryInitializationOutcome() {
}
public boolean isFailure() {
return this.outcome == Outcome.FAILURE;
}
public boolean isSuccess() {
return this.outcome == Outcome.SUCCESS;
}
public static LibraryInitializationOutcome success() {
return new LibraryInitializationOutcome(Outcome.SUCCESS, null);
}
public static LibraryInitializationOutcome failure() {
return new LibraryInitializationOutcome(Outcome.FAILURE, "Library initialization failure");
}
public static LibraryInitializationOutcome failure(String msg) {
return new LibraryInitializationOutcome(Outcome.FAILURE, msg);
}
public Outcome getOutcome() {
return outcome;
}
public String getFailureMessage() {
return failureMessage;
}
}