• 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

71.43
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JWildcardType.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.function.Function;
8
import java.util.function.Predicate;
9
import java.util.stream.Stream;
10

11
import org.checkerframework.checker.nullness.qual.NonNull;
12
import org.pcollections.PSet;
13

14
import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol;
15
import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot;
16

17
/**
18
 * Represents a wildcard type. Such types are converted to {@link JTypeVar}
19
 * by {@linkplain TypeConversion#capture(JTypeMirror) capture conversion}.
20
 *
21
 * <p>This implements JTypeMirror for convenience, however, it may only
22
 * occur as a type argument, and as such some of the behaviour of JTypeMirror
23
 * is undefined: {@link #isSubtypeOf(JTypeMirror) subtyping} and {@link #getErasure() erasure}.
24
 */
25
public interface JWildcardType extends JTypeMirror {
26

27

28
    /** Returns the bound. Interpretation is given by {@link #isUpperBound()}. */
29
    @NonNull
30
    JTypeMirror getBound();
31

32

33

34
    /** Returns true if this is an "extends" wildcard, with no bound ("?"). */
35
    default boolean isUnbounded() {
36
        return isUpperBound() && getBound().isTop();
1✔
37
    }
38

39

40
    /** Returns true if this is an "extends" wildcard, the bound is then an upper bound. */
41
    boolean isUpperBound();
42

43

44
    /** Returns true if this is a "super" wildcard, the bound is then a lower bound. */
45
    default boolean isLowerBound() {
46
        return !isUpperBound();
1✔
47
    }
48

49

50
    /** Returns the lower bound, or the bottom type if this is an "extends" wildcard. */
51
    default @NonNull JTypeMirror asLowerBound() {
52
        return isUpperBound() ? getTypeSystem().NULL_TYPE : getBound();
1✔
53
    }
54

55

56
    /** Returns the upper bound, or Object if this is a "super" wildcard. */
57
    default @NonNull JTypeMirror asUpperBound() {
58
        return isUpperBound() ? getBound() : getTypeSystem().OBJECT;
1✔
59
    }
60

61

62
    /**
63
     * This is implemented for convenience. However, the erasure of a
64
     * wildcard type is undefined and useless. This is because they can
65
     * only occur in type arguments, which are erased themselves.
66
     */
67
    @Override
68
    default JTypeMirror getErasure() {
69
        return this;
×
70
    }
71

72
    @Override
73
    default Stream<JMethodSig> streamMethods(Predicate<? super JMethodSymbol> prefilter) {
74
        return asUpperBound().streamMethods(prefilter);
×
75
    }
76

77
    @Override
78
    JWildcardType subst(Function<? super SubstVar, ? extends @NonNull JTypeMirror> subst);
79

80
    @Override
81
    JWildcardType withAnnotations(PSet<SymAnnot> newTypeAnnots);
82

83
    @Override
84
    default <T, P> T acceptVisitor(JTypeVisitor<T, P> visitor, P p) {
85
        return visitor.visitWildcard(this, p);
1✔
86
    }
87

88
}
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