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

com.yahoo.vespa.hosted.controller.api.integration.billing.CollectionResult Maven / Gradle / Ivy

There is a newer version: 8.253.3
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.billing;

import java.util.Objects;
import java.util.Optional;

/**
 * Object to carry the result of {@link BillingController#setCollectionMethod}
 *
 * @author smorgrav
 */
public class CollectionResult {

    private final Optional errorMessage;

    private CollectionResult(Optional errorMessage) {
        this.errorMessage = errorMessage;
    }

    public static CollectionResult success() {
        return new CollectionResult(Optional.empty());
    }

    public static CollectionResult error(String errorMessage) {
        return new CollectionResult(Optional.of(errorMessage));
    }

    public boolean isSuccess() {
        return errorMessage.isEmpty();
    }

    public Optional getErrorMessage() {
        return errorMessage;
    }

    @Override
    public String toString() {
        return "CollectionResult{" +
                "errorMessage=" + errorMessage +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CollectionResult that = (CollectionResult) o;
        return Objects.equals(errorMessage, that.errorMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(errorMessage);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy