Ejemplo n.º 1
0
    public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
      // require an owner type if the raw type needs it
      if (rawType instanceof Class<?>) {
        Class<?> rawTypeAsClass = (Class<?>) rawType;
        try {
          Assert.isTrue(ownerType != null || rawTypeAsClass.getEnclosingClass() == null);
          Assert.isTrue(ownerType == null || rawTypeAsClass.getEnclosingClass() != null);
        } catch (RuntimeException e) {
          // R][2011-09-27 21:08:14,570] [ORM._log] ownerType:null
          // [ERROR][2011-09-27 21:08:14,572] [ORM._log]
          // rawTypeAsClass:interface java.util.Map$Entry
          // [ERROR][2011-09-27 21:08:14,573] [ORM._log]
          // getEnclosingClass:interface java.util.Map

          LogUtil.error("ownerType:" + ownerType);
          LogUtil.error("rawTypeAsClass:" + rawTypeAsClass);
          LogUtil.error("getEnclosingClass:" + rawTypeAsClass.getEnclosingClass());
          throw e;
        }
      }

      this.ownerType = ownerType == null ? null : canonicalize(ownerType);
      this.rawType = canonicalize(rawType);
      this.typeArguments = typeArguments.clone();
      for (int t = 0; t < this.typeArguments.length; t++) {
        Assert.notNull(this.typeArguments[t]);
        checkNotPrimitive(this.typeArguments[t]);
        this.typeArguments[t] = canonicalize(this.typeArguments[t]);
      }
    }
Ejemplo n.º 2
0
    public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
      Assert.isTrue(lowerBounds.length <= 1);
      Assert.isTrue(upperBounds.length == 1);

      if (lowerBounds.length == 1) {
        Assert.notNull(lowerBounds[0]);
        checkNotPrimitive(lowerBounds[0]);
        Assert.isTrue(upperBounds[0] == Object.class);
        this.lowerBound = canonicalize(lowerBounds[0]);
        this.upperBound = Object.class;

      } else {
        Assert.notNull(upperBounds[0]);
        checkNotPrimitive(upperBounds[0]);
        this.lowerBound = null;
        this.upperBound = canonicalize(upperBounds[0]);
      }
    }
Ejemplo n.º 3
0
 private static void checkNotPrimitive(Type type) {
   Assert.isTrue(!(type instanceof Class<?>) || !((Class<?>) type).isPrimitive());
 }