Java Code Examples for java.lang.reflect.Type#clone()

The following examples show how to use java.lang.reflect.Type#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Types.java    From Jolyglot with Apache License 2.0 6 votes vote down vote up
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;
    boolean isStaticOrTopLevelClass = Modifier.isStatic(rawTypeAsClass.getModifiers())
        || rawTypeAsClass.getEnclosingClass() == null;
    if (ownerType == null && !isStaticOrTopLevelClass) throw new IllegalArgumentException();
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    if (this.typeArguments[t] == null) throw new NullPointerException();
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 2
Source File: TypeUtil.java    From dagger-reflect with Apache License 2.0 6 votes vote down vote up
ParameterizedTypeImpl(@Nullable Type ownerType, Type rawType, Type... typeArguments) {
  // Require an owner type if the raw type needs it.
  if (rawType instanceof Class<?>) {
    Class<?> enclosingClass = ((Class<?>) rawType).getEnclosingClass();
    if (ownerType != null) {
      if (enclosingClass == null || Types.getRawType(ownerType) != enclosingClass) {
        throw new IllegalArgumentException(
            "unexpected owner type for " + rawType + ": " + ownerType);
      }
    } else if (enclosingClass != null) {
      throw new IllegalArgumentException("unexpected owner type for " + rawType + ": null");
    }
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    if (this.typeArguments[t] == null) throw new NullPointerException();
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 3
Source File: $Gson$Types.java    From GVGAI_GYM with Apache License 2.0 6 votes vote down vote up
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;
    boolean isStaticOrTopLevelClass = Modifier.isStatic(rawTypeAsClass.getModifiers())
        || rawTypeAsClass.getEnclosingClass() == null;
    checkArgument(ownerType != null || isStaticOrTopLevelClass);
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0, length = this.typeArguments.length; t < length; t++) {
    checkNotNull(this.typeArguments[t]);
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 4
Source File: $Gson$Types.java    From GVGAI_GYM with Apache License 2.0 6 votes vote down vote up
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;
    boolean isStaticOrTopLevelClass = Modifier.isStatic(rawTypeAsClass.getModifiers())
        || rawTypeAsClass.getEnclosingClass() == null;
    checkArgument(ownerType != null || isStaticOrTopLevelClass);
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0, length = this.typeArguments.length; t < length; t++) {
    checkNotNull(this.typeArguments[t]);
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 5
Source File: Util.java    From moshi with Apache License 2.0 6 votes vote down vote up
public ParameterizedTypeImpl(@Nullable Type ownerType, Type rawType, Type... typeArguments) {
  // Require an owner type if the raw type needs it.
  if (rawType instanceof Class<?>) {
    Class<?> enclosingClass = ((Class<?>) rawType).getEnclosingClass();
    if (ownerType != null) {
      if (enclosingClass == null || Types.getRawType(ownerType) != enclosingClass) {
        throw new IllegalArgumentException(
            "unexpected owner type for " + rawType + ": " + ownerType);
      }
    } else if (enclosingClass != null) {
      throw new IllegalArgumentException(
          "unexpected owner type for " + rawType + ": null");
    }
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    if (this.typeArguments[t] == null) throw new NullPointerException();
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 6
Source File: $Gson$Types.java    From framework with GNU Affero General Public License v3.0 6 votes vote down vote up
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;
    boolean isStaticOrTopLevelClass = Modifier.isStatic(rawTypeAsClass.getModifiers())
        || rawTypeAsClass.getEnclosingClass() == null;
    checkArgument(ownerType != null || isStaticOrTopLevelClass);
  }

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    checkNotNull(this.typeArguments[t]);
    checkNotPrimitive(this.typeArguments[t]);
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 7
Source File: MoreTypes.java    From crate with Apache License 2.0 6 votes vote down vote up
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;
        if (ownerType == null && rawTypeAsClass.getEnclosingClass() != null) {
            throw new IllegalArgumentException("No owner type for enclosed " + rawType);
        }
        if (ownerType != null && rawTypeAsClass.getEnclosingClass() == null) {
            throw new IllegalArgumentException("Owner type for unenclosed " + rawType);
        }

    }

    this.ownerType = ownerType == null ? null : canonicalize(ownerType);
    this.rawType = canonicalize(rawType);
    this.typeArguments = typeArguments.clone();
    for (int t = 0; t < this.typeArguments.length; t++) {
        Objects.requireNonNull(this.typeArguments[t], "type parameter");
        checkNotPrimitive(this.typeArguments[t], "type parameters");
        this.typeArguments[t] = canonicalize(this.typeArguments[t]);
    }
}
 
Example 8
Source File: Types.java    From feign with Apache License 2.0 6 votes vote down vote up
ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
  // Require an owner type if the raw type needs it.
  if (rawType instanceof Class<?>
      && (ownerType == null) != (((Class<?>) rawType).getEnclosingClass() == null)) {
    throw new IllegalArgumentException();
  }

  this.ownerType = ownerType;
  this.rawType = rawType;
  this.typeArguments = typeArguments.clone();

  for (Type typeArgument : this.typeArguments) {
    if (typeArgument == null) {
      throw new NullPointerException();
    }
    checkNotPrimitive(typeArgument);
  }
}
 
Example 9
Source File: MoreTypes.java    From soabase-halva with Apache License 2.0 5 votes vote down vote up
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
  // require an owner type if the raw type needs it
  ensureOwnerType(ownerType, rawType);

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    checkNotNull(this.typeArguments[t], "type parameter");
    checkNotPrimitive(this.typeArguments[t], "type parameters");
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 10
Source File: TestTypeResolver.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 11
Source File: RetroTypes.java    From wasp with Apache License 2.0 5 votes vote down vote up
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
  // Require an owner type if the raw type needs it.
  if (rawType instanceof Class<?>
      && (ownerType == null) != (((Class<?>) rawType).getEnclosingClass() == null)) {
    throw new IllegalArgumentException();
  }
  this.ownerType = ownerType;
  this.rawType = rawType;
  this.typeArguments = typeArguments.clone();
  for (Type typeArgument : this.typeArguments) {
    if (typeArgument == null) throw new NullPointerException();
    checkNotPrimitive(typeArgument);
  }
}
 
Example 12
Source File: TestTypeResolver.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 13
Source File: MoreTypes.java    From businessworks with Apache License 2.0 5 votes vote down vote up
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
  // require an owner type if the raw type needs it
  ensureOwnerType(ownerType, rawType);

  this.ownerType = ownerType == null ? null : canonicalize(ownerType);
  this.rawType = canonicalize(rawType);
  this.typeArguments = typeArguments.clone();
  for (int t = 0; t < this.typeArguments.length; t++) {
    checkNotNull(this.typeArguments[t], "type parameter");
    checkNotPrimitive(this.typeArguments[t], "type parameters");
    this.typeArguments[t] = canonicalize(this.typeArguments[t]);
  }
}
 
Example 14
Source File: TestTypeResolver.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 15
Source File: TestTypeResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 16
Source File: TypeUtils.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
    // Require an owner type if the raw type needs it.
    if (rawType instanceof Class<?> && (ownerType == null) != (((Class<?>) rawType).getEnclosingClass() == null)) {
        throw new IllegalArgumentException();
    }

    this.ownerType = ownerType;
    this.rawType = rawType;
    this.typeArguments = typeArguments.clone();

    for (Type typeArgument : this.typeArguments) {
        if (typeArgument == null) throw new NullPointerException();
        checkNotPrimitive(typeArgument);
    }
}
 
Example 17
Source File: TestTypeResolver.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 18
Source File: TestTypeResolver.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 19
Source File: TestTypeResolver.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
TypeVariableImpl(String name, D gd, Type... bounds) {
    this.name = name;
    this.gd = gd;
    if (bounds.length == 0)
        bounds = new Type[] {Object.class};
    this.bounds = bounds.clone();
}
 
Example 20
Source File: AttributeTypes.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
ParameterizedTypeImpl(Class<?> rawType, Type... typeArguments) {
   this.rawType = rawType;
   this.typeArguments = typeArguments.clone();
}