Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1035536 // GenericArrayTypeImpl - from JDK

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (79L/1K).

1  
sclass GenericArrayTypeImpl is GenericArrayType {
2  
    private final Type genericComponentType;
3  
4  
    // private constructor enforces use of static factory
5  
    private GenericArrayTypeImpl(Type ct) {
6  
        genericComponentType = ct;
7  
    }
8  
9  
    /**
10  
     * Factory method.
11  
     * @param ct - the desired component type of the generic array type
12  
     * being created
13  
     * @return a generic array type with the desired component type
14  
     */
15  
    public static GenericArrayTypeImpl make(Type ct) {
16  
        return new GenericArrayTypeImpl(ct);
17  
    }
18  
19  
20  
    /**
21  
     * Returns a {@code Type} object representing the component type
22  
     * of this array.
23  
     *
24  
     * @return a {@code Type} object representing the component type
25  
     *     of this array
26  
     * @since 1.5
27  
     */
28  
    public Type getGenericComponentType() {
29  
        return genericComponentType; // return cached component type
30  
    }
31  
32  
    public String toString() {
33  
        return getGenericComponentType().getTypeName() + "[]";
34  
    }
35  
36  
    @Override
37  
    public boolean equals(Object o) {
38  
        if (o instanceof GenericArrayType) {
39  
            GenericArrayType that = (GenericArrayType) o;
40  
41  
            return Objects.equals(genericComponentType, that.getGenericComponentType());
42  
        } else
43  
            return false;
44  
    }
45  
46  
    @Override
47  
    public int hashCode() {
48  
        return Objects.hashCode(genericComponentType);
49  
    }
50  
}

Author comment

Began life as a copy of #1029596

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035536
Snippet name: GenericArrayTypeImpl - from JDK
Eternal ID of this version: #1035536/1
Text MD5: c7cfcde55f3fd67b84d64078a6a009ad
Transpilation MD5: 551f17739e86e33aea1f84ee303ed8de
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-04 09:45:37
Source code size: 1443 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 120 / 194
Referenced in: [show references]