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

net.nemerosa.ontrack.model.support.ConnectionResult Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.model.support;

import lombok.Data;

import java.util.function.Function;

/**
 * Result of a connection test.
 */
@Data
public class ConnectionResult {

    public enum ConnectionResultType {
        OK, ERROR
    }

    private final ConnectionResultType type;
    private final String message;

    public static ConnectionResult ok() {
        return new ConnectionResult(ConnectionResultType.OK, "");
    }

    public static ConnectionResult error(String message) {
        return new ConnectionResult(ConnectionResultType.ERROR, message);
    }

    public void onErrorThrow(Function errorCreation) {
        if (type == ConnectionResultType.ERROR) {
            throw errorCreation.apply(message);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy