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

pmd / pmd / #3722

pending completion
#3722

push

github actions

adangel
Suppress MissingOverride for Chars::isEmpty (#4291)

67270 of 127658 relevant lines covered (52.7%)

0.53 hits per line

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

54.29
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/CaptureMatcher.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.types;
6

7
import java.util.Objects;
8
import java.util.function.Function;
9

10
import org.checkerframework.checker.nullness.qual.NonNull;
11
import org.checkerframework.checker.nullness.qual.Nullable;
12
import org.pcollections.HashTreePSet;
13
import org.pcollections.PSet;
14

15
import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol;
16
import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot;
17

18
/**
19
 * Test only. This binds to the first capture variable it tests equal
20
 * with, and keeps the same binding forever.
21
 */
22
final class CaptureMatcher implements JTypeVar {
23

24
    private final JWildcardType wild;
25
    private @Nullable JTypeVar captured = null;
1✔
26

27
    CaptureMatcher(JWildcardType wild) {
1✔
28
        this.wild = wild;
1✔
29
    }
1✔
30

31
    @Override
32
    public TypeSystem getTypeSystem() {
33
        return wild.getTypeSystem();
×
34
    }
35

36
    @Override
37
    public boolean isCaptured() {
38
        return true;
1✔
39
    }
40

41
    @Override
42
    public JTypeVar withAnnotations(PSet<SymAnnot> newTypeAnnots) {
43
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
44
    }
45

46
    @Override
47
    public JTypeVar withUpperBound(@NonNull JTypeMirror newUB) {
48
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
49
    }
50

51
    @Override
52
    public PSet<SymAnnot> getTypeAnnotations() {
53
        if (captured != null) {
×
54
            return captured.getTypeAnnotations();
×
55
        }
56
        return HashTreePSet.empty();
×
57
    }
58

59
    @Override
60
    public @Nullable JTypeParameterSymbol getSymbol() {
61
        return null; // captured
×
62
    }
63

64
    @Override
65
    public @NonNull String getName() {
66
        if (captured != null) {
×
67
            return captured.getName();
×
68
        }
69
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
70
    }
71

72
    @Override
73
    public @NonNull JTypeMirror getUpperBound() {
74
        return captured != null ? captured.getUpperBound() : getTypeSystem().OBJECT;
1✔
75
    }
76

77
    @Override
78
    public @NonNull JTypeMirror getLowerBound() {
79
        return captured != null ? captured.getLowerBound() : getTypeSystem().NULL_TYPE;
1✔
80
    }
81

82
    @Override
83
    public boolean isCaptureOf(JWildcardType wildcard) {
84
        return this.wild.equals(wildcard);
1✔
85
    }
86

87
    @Override
88
    public @Nullable JWildcardType getCapturedOrigin() {
89
        return wild;
1✔
90
    }
91

92
    @Override
93
    public JTypeVar cloneWithBounds(JTypeMirror lower, JTypeMirror upper) {
94
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
95
    }
96

97
    @Override
98
    public JTypeVar substInBounds(Function<? super SubstVar, ? extends @NonNull JTypeMirror> substitution) {
99
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
100
    }
101

102
    @Override
103
    public boolean equals(Object o) {
104
        if (this == o) {
1✔
105
            return true;
×
106
        }
107
        if (!(o instanceof JTypeVar)) {
1✔
108
            return false;
×
109
        }
110
        if (captured != null) {
1✔
111
            return captured.equals(o);
1✔
112
        }
113

114
        JTypeVar that = (JTypeVar) o;
1✔
115
        if (!Objects.equals(that.getCapturedOrigin(), this.getCapturedOrigin())) {
1✔
116
            return false;
×
117
        }
118
        this.captured = that;
1✔
119
        return true;
1✔
120
    }
121

122
    @Override
123
    public int hashCode() {
124
        throw new UnsupportedOperationException("this is a test only object which should only be used for equals");
×
125
    }
126

127
    @Override
128
    public String toString() {
129
        return captured == null ? "unbound capture matcher"
1✔
130
                                : "bound(" + captured.toString() + ")";
1✔
131
    }
132
}
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

© 2026 Coveralls, Inc