• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.62
/commons/util/src/main/java/net/automatalib/common/util/Triple.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.common.util;
17

18
import java.io.IOException;
19
import java.util.Objects;
20

21
import net.automatalib.common.util.string.AbstractPrintable;
22
import net.automatalib.common.util.string.StringUtil;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24

25
/**
26
 * Immutable triple class.
27
 * <p>
28
 * <b>Note</b>: this class should only be used for internal representations of tuples with value type semantics (e.g.
29
 * equality, only if all components are equal).
30
 * <p>
31
 * Whenever a public interface returns an aggregation of individual objects, a separate class should be created/used
32
 * that has meaningful identifiers for the individual components.
33
 *
34
 * @param <T1>
35
 *         type of the first component
36
 * @param <T2>
37
 *         type of the second component
38
 * @param <T3>
39
 *         type of the third component
40
 */
41
public final class Triple<T1, T2, T3> extends AbstractPrintable {
42

43
    private final T1 first;
44
    private final T2 second;
45
    private final T3 third;
46

47
    private Triple(T1 first, T2 second, T3 third) {
1✔
48
        this.first = first;
1✔
49
        this.second = second;
1✔
50
        this.third = third;
1✔
51
    }
1✔
52

53
    /**
54
     * Creates a new triple from the given components.
55
     *
56
     * @param first
57
     *         the first triple component
58
     * @param second
59
     *         the second triple component
60
     * @param third
61
     *         the third triple component
62
     * @param <T1>
63
     *         type of the first component
64
     * @param <T2>
65
     *         type of the second component
66
     * @param <T3>
67
     *         type of the third component
68
     *
69
     * @return the new triple object
70
     */
71
    public static <T1, T2, T3> Triple<T1, T2, T3> of(T1 first, T2 second, T3 third) {
72
        return new Triple<>(first, second, third);
1✔
73
    }
74

75
    public T1 getFirst() {
76
        return first;
1✔
77
    }
78

79
    public T2 getSecond() {
80
        return second;
1✔
81
    }
82

83
    public T3 getThird() {
84
        return third;
1✔
85
    }
86

87
    @Override
88
    public void print(Appendable a) throws IOException {
89
        a.append('(');
1✔
90
        StringUtil.appendObject(a, first);
1✔
91
        a.append(", ");
1✔
92
        StringUtil.appendObject(a, second);
1✔
93
        a.append(", ");
1✔
94
        StringUtil.appendObject(a, third);
1✔
95
        a.append(')');
1✔
96
    }
1✔
97

98
    @Override
99
    public boolean equals(@Nullable Object o) {
100
        if (this == o) {
×
101
            return true;
×
102
        }
103
        if (!(o instanceof Triple)) {
×
104
            return false;
×
105
        }
106

107
        final Triple<?, ?, ?> that = (Triple<?, ?, ?>) o;
×
108
        return Objects.equals(first, that.first) && Objects.equals(second, that.second) &&
×
109
               Objects.equals(third, that.third);
×
110
    }
111

112
    @Override
113
    public int hashCode() {
114
        int result = 1;
×
115
        result = 31 * result + Objects.hashCode(first);
×
116
        result = 31 * result + Objects.hashCode(second);
×
117
        result = 31 * result + Objects.hashCode(third);
×
118
        return result;
×
119
    }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc