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).

sclass GenericArrayTypeImpl is GenericArrayType {
    private final Type genericComponentType;

    // private constructor enforces use of static factory
    private GenericArrayTypeImpl(Type ct) {
        genericComponentType = ct;
    }

    /**
     * Factory method.
     * @param ct - the desired component type of the generic array type
     * being created
     * @return a generic array type with the desired component type
     */
    public static GenericArrayTypeImpl make(Type ct) {
        return new GenericArrayTypeImpl(ct);
    }


    /**
     * Returns a {@code Type} object representing the component type
     * of this array.
     *
     * @return a {@code Type} object representing the component type
     *     of this array
     * @since 1.5
     */
    public Type getGenericComponentType() {
        return genericComponentType; // return cached component type
    }

    public String toString() {
        return getGenericComponentType().getTypeName() + "[]";
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof GenericArrayType) {
            GenericArrayType that = (GenericArrayType) o;

            return Objects.equals(genericComponentType, that.getGenericComponentType());
        } else
            return false;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(genericComponentType);
    }
}

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: 121 / 196
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)