Class WildcardTypeImpl

java.lang.Object
cloud.opencode.base.reflect.type.WildcardTypeImpl
All Implemented Interfaces:
Type, WildcardType

public final class WildcardTypeImpl extends Object implements WildcardType
Wildcard Type Implementation 通配符类型实现

Implementation of WildcardType for runtime type construction.

用于运行时类型构造的WildcardType实现。

Features | 主要功能:

  • WildcardType runtime construction - WildcardType运行时构造
  • Upper and lower bounds support - 上界和下界支持
  • Proper equals/hashCode/toString - 正确的equals/hashCode/toString

Usage Examples | 使用示例:

// ? extends Number
WildcardType upper = new WildcardTypeImpl(new Type[]{Number.class}, new Type[0]);

// ? super Integer
WildcardType lower = new WildcardTypeImpl(new Type[]{Object.class}, new Type[]{Integer.class});

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: No (bounds arrays must be non-null) - 空值安全: 否(边界数组须非空)
Since:
JDK 25, opencode-base-reflect V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • WildcardTypeImpl

      public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds)
      Creates a wildcard type 创建通配符类型
      Parameters:
      upperBounds - the upper bounds | 上界
      lowerBounds - the lower bounds | 下界
  • Method Details

    • extendsOf

      public static WildcardTypeImpl extendsOf(Type upperBound)
      Creates a wildcard with upper bound (? extends T) 创建带上界的通配符(? extends T)
      Parameters:
      upperBound - the upper bound | 上界
      Returns:
      wildcard type | 通配符类型
    • superOf

      public static WildcardTypeImpl superOf(Type lowerBound)
      Creates a wildcard with lower bound (? super T) 创建带下界的通配符(? super T)
      Parameters:
      lowerBound - the lower bound | 下界
      Returns:
      wildcard type | 通配符类型
    • unbounded

      public static WildcardTypeImpl unbounded()
      Creates an unbounded wildcard (?) 创建无界通配符(?)
      Returns:
      wildcard type | 通配符类型
    • getUpperBounds

      public Type[] getUpperBounds()
      Specified by:
      getUpperBounds in interface WildcardType
    • getLowerBounds

      public Type[] getLowerBounds()
      Specified by:
      getLowerBounds in interface WildcardType
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object