fr.arakne.swflangloader.parser.Assignation   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 94.74%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
c 1
b 0
f 0
dl 0
loc 73
ccs 18
cts 19
cp 0.9474
rs 10
wmc 12

9 Methods

Rating   Name   Duplication   Size   Complexity  
A isAssociative() 0 2 1
A equals(Object) 0 8 4
A key() 0 2 1
A Assignation(String,Object,Object) 0 4 1
A simple(String,Object) 0 2 1
A isNull() 0 2 1
A variableName() 0 2 1
A hashCode() 0 3 1
A value() 0 2 1
1
/*
2
 * This file is part of ArakneLangLoader.
3
 *
4
 * ArakneLangLoader is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * ArakneLangLoader is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with ArakneLangLoader.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2020 Vincent Quatrevieux
18
 */
19
20
package fr.arakne.swflangloader.parser;
21
22
import java.util.Objects;
23
24
/**
25
 * DTO for action script assignation operation
26
 */
27
final public class Assignation {
28 1
    final static public Assignation NULL = new Assignation(null, null, null);
29
30
    final private String variableName;
31
    final private Object key;
32
    final private Object value;
33
34 1
    public Assignation(String variableName, Object key, Object value) {
35 1
        this.variableName = variableName;
36 1
        this.key = key;
37 1
        this.value = value;
38 1
    }
39
40
    /**
41
     * @return The assigned variable name
42
     */
43
    public String variableName() {
44 1
        return variableName;
45
    }
46
47
    /**
48
     * @return The assigned object key. Null if not associative assignation
49
     */
50
    public Object key() {
51 1
        return key;
52
    }
53
54
    /**
55
     * @return The assigned value
56
     */
57
    public Object value() {
58 1
        return value;
59
    }
60
61
    /**
62
     * @return true if it's a null assignation (mustbe skipped)
63
     */
64
    public boolean isNull() {
65 1
        return variableName == null;
66
    }
67
68
    /**
69
     * @return true if it's an associative assignation
70
     */
71
    public boolean isAssociative() {
72 1
        return key != null;
73
    }
74
75
    @Override
76
    public boolean equals(Object o) {
77 1
        if (this == o) return true;
78 1
        if (o == null || getClass() != o.getClass()) return false;
79 1
        Assignation that = (Assignation) o;
80 1
        return Objects.equals(variableName, that.variableName) &&
81 1
            Objects.equals(key, that.key) &&
82 1
            Objects.equals(value, that.value);
83
    }
84
85
    @Override
86
    public int hashCode() {
87
        return Objects.hash(variableName, key, value);
88
    }
89
90
    /**
91
     * Create a simple (i.e. not associative) assignation
92
     *
93
     * @param varName The assigned variable
94
     * @param value The assigned value
95
     *
96
     * @return The assignation
97
     */
98
    static public Assignation simple(String varName, Object value) {
99 1
        return new Assignation(varName, null, value);
100
    }
101
}
102