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

nebula.plugin.metrics.model.Result Maven / Gradle / Ivy

Go to download

Gradle Metrics plugin: Collects gradle metrics and publishes to ElasticSearch HTTP/Splunk/REST endpoints

There is a newer version: 10.1.8
Show newest version
/*
 *  Copyright 2015-2016 Netflix, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package nebula.plugin.metrics.model;

import com.google.common.base.Throwables;
import lombok.NonNull;
import lombok.Value;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Result.
 */
@Value
public class Result {
    public static Result unknown() {
        return create(ResultStatus.UNKNOWN);
    }

    public static Result success() {
        return create(ResultStatus.SUCCESS);
    }

    public static Result failure(Throwable throwable) {
        return failure(Arrays.asList(throwable));
    }

    public static Result failure(Iterable failures) {
        checkNotNull(failures);
        List stringFailures = new ArrayList<>();
        for (Throwable throwable : failures) {
            stringFailures.add(Throwables.getStackTraceAsString(throwable));
        }
        return new Result(ResultStatus.FAILURE, stringFailures);
    }

    public static Result skipped() {
        return create(ResultStatus.SKIPPED);
    }

    private static Result create(ResultStatus status) {
        return new Result(status, null);
    }

    @NonNull
    private ResultStatus status;

    private List failures;

    public enum ResultStatus {
        UNKNOWN,
        SUCCESS,
        FAILURE,
        SKIPPED
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy