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

leeonky / test-charm-java / 320

28 Sep 2025 03:56PM UTC coverage: 74.512% (+0.07%) from 74.442%
320

push

circleci

leeonky
one list one property

21 of 21 new or added lines in 2 files covered. (100.0%)

13 existing lines in 7 files now uncovered.

8466 of 11362 relevant lines covered (74.51%)

0.75 hits per line

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

94.74
/bean-util/src/main/java/com/github/leeonky/util/GenericType.java
1
package com.github.leeonky.util;
2

3
import java.lang.reflect.ParameterizedType;
4
import java.lang.reflect.Type;
5
import java.lang.reflect.TypeVariable;
6
import java.util.Map;
7
import java.util.Objects;
8
import java.util.Optional;
9
import java.util.concurrent.ConcurrentHashMap;
10

11
public class GenericType {
12
    private final static Map<Type, GenericType> instanceCache = new ConcurrentHashMap<>();
1✔
13
    private final Type type;
14

15
    private GenericType(Type type) {
1✔
16
        this.type = Objects.requireNonNull(type);
1✔
17
    }
1✔
18

19
    public static GenericType createGenericType(Type type) {
20
        return instanceCache.computeIfAbsent(type, GenericType::new);
1✔
21
    }
22

23
    public Class<?> getRawType() {
24
        if (type instanceof ParameterizedType)
1✔
25
            return (Class<?>) ((ParameterizedType) type).getRawType();
1✔
26
        if (type instanceof TypeVariable)
1✔
UNCOV
27
            return Object.class;
×
28
        return (Class<?>) type;
1✔
29
    }
30

31
    public Optional<GenericType> getGenericTypeParameter(int parameterIndex) {
32
        if (type instanceof ParameterizedType) {
1✔
33
            Type typeArgument = ((ParameterizedType) type).getActualTypeArguments()[parameterIndex];
1✔
34
            if (typeArgument instanceof Class || typeArgument instanceof ParameterizedType)
1✔
35
                return Optional.of(new GenericType(typeArgument));
1✔
36
        }
37
        return Optional.empty();
1✔
38
    }
39

40
    public boolean hasTypeArguments() {
41
        return type instanceof ParameterizedType;
1✔
42
    }
43

44
    @Override
45
    public int hashCode() {
46
        return Objects.hash(GenericType.class, type);
1✔
47
    }
48

49
    @Override
50
    public boolean equals(Object obj) {
51
        return obj instanceof GenericType && Objects.equals(type, ((GenericType) obj).type);
1✔
52
    }
53

54
    public Type getGenericType() {
55
        return type;
1✔
56
    }
57
}
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