Passed
Push — master ( 27e47c...011406 )
by Vincent
03:32
created

fr.arakne.utils.value.Dimensions.width()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 2
cc 1
rs 10
ccs 1
cts 1
cp 1
crap 1
1
/*
2
 * This file is part of ArakneUtils.
3
 *
4
 * ArakneUtils 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
 * ArakneUtils 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 ArakneUtils.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2020 Vincent Quatrevieux
18
 */
19
20
package fr.arakne.utils.value;
21
22
import java.util.Objects;
23
24
/**
25
 * Dimensions for 2D object
26
 */
27
final public class Dimensions {
28
    final private int width;
29
    final private int height;
30
31 1
    public Dimensions(int width, int height) {
32 1
        this.width = width;
33 1
        this.height = height;
34 1
    }
35
36
    /**
37
     * Get the width
38
     */
39
    public int width() {
40 1
        return width;
41
    }
42
43
    /**
44
     * Get the height
45
     */
46
    public int height() {
47 1
        return height;
48
    }
49
50
    @Override
51
    public boolean equals(Object o) {
52 1
        if (this == o) {
53 1
            return true;
54
        }
55
56 1
        if (o == null || getClass() != o.getClass()) {
57 1
            return false;
58
        }
59
60 1
        Dimensions other = (Dimensions) o;
61
62 1
        return other.height == height && other.width == width;
63
    }
64
65
    @Override
66
    public int hashCode() {
67 1
        return Objects.hash(width, height);
68
    }
69
70
    @Override
71
    public String toString() {
72 1
        return "Dimensions(" + width + "x" + height + ')';
73
    }
74
}
75