OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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