fr.arakne.utils.value.Dimensions   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A height() 0 3 1
A width() 0 3 1
A Dimensions(int,int) 0 3 1
A toString() 0 3 1
A hashCode() 0 3 1
A equals(Object) 0 13 4
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 org.checkerframework.checker.index.qual.Positive;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24
import org.checkerframework.dataflow.qual.Pure;
25
26
import java.util.Objects;
27
28
/**
29
 * Dimensions for 2D object
30
 */
31
public final class Dimensions {
32
    private final @Positive int width;
33
    private final @Positive int height;
34
35 1
    public Dimensions(@Positive int width, @Positive int height) {
36 1
        this.width = width;
37 1
        this.height = height;
38 1
    }
39
40
    /**
41
     * Get the width
42
     *
43
     * @return The width
44
     */
45
    @Pure
46
    public @Positive int width() {
47 1
        return width;
48
    }
49
50
    /**
51
     * Get the height
52
     *
53
     * @return The height
54
     */
55
    @Pure
56
    public @Positive int height() {
57 1
        return height;
58
    }
59
60
    @Override
61
    public boolean equals(@Nullable Object o) {
62 1
        if (this == o) {
63 1
            return true;
64
        }
65
66 1
        if (o == null || getClass() != o.getClass()) {
67 1
            return false;
68
        }
69
70 1
        final Dimensions other = (Dimensions) o;
71
72 1
        return other.height == height && other.width == width;
73
    }
74
75
    @Override
76
    public int hashCode() {
77 1
        return Objects.hash(width, height);
78
    }
79
80
    @Override
81
    public String toString() {
82 1
        return "Dimensions(" + width + "x" + height + ')';
83
    }
84
}
85