OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
80 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.modules;
15
 
156 ilm 16
import java.util.Objects;
17
 
80 ilm 18
public class DepSolverResult {
19
 
20
    static public interface Factory {
21
        DepSolverResult create(DepSolverResult parent, int tryCount, String error, DepSolverGraph graph);
22
    }
23
 
24
    private final DepSolverResult parent;
25
    private final int triesCount;
26
    private final String error;
27
    private final DepSolverGraph graph;
28
 
29
    public DepSolverResult(DepSolverResult parent, int tryCount, String error, DepSolverGraph graph) {
30
        super();
31
        this.parent = parent;
156 ilm 32
        if (tryCount < 0)
33
            throw new IllegalArgumentException("Negative try count : " + tryCount);
80 ilm 34
        this.triesCount = tryCount;
35
        this.error = error;
156 ilm 36
        this.graph = Objects.requireNonNull(graph, "graph");
80 ilm 37
    }
38
 
39
    /**
40
     * The result that led to this one. E.g. there could have been a missing dependency for the
41
     * latest version of a module and thus this result contains an older version of the module.
42
     *
43
     * @return the parent result.
44
     */
45
    public final DepSolverResult getParent() {
46
        return this.parent;
47
    }
48
 
49
    /**
50
     * The number of tries before obtaining this result.
51
     *
52
     * @return the tries count, starts at 0.
53
     */
54
    public final int getTriesCount() {
55
        return this.triesCount;
56
    }
57
 
58
    public final String getError() {
59
        return this.error;
60
    }
61
 
62
    public final DepSolverGraph getGraph() {
63
        return this.graph;
64
    }
65
 
66
    @Override
67
    public String toString() {
68
        return this.getClass().getSimpleName() + (this.getError() == null ? " no errors" : (" error : " + this.getError()));
69
    }
70
}