Optimization: move ParameterizedTypeImpl checks out of line.
No functional changes.
This will allow android apps to remove this method
via proguard in release mode.
For everything else, it should be almost a no-op, just one extra
indirection.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83477074
diff --git a/core/src/com/google/inject/internal/MoreTypes.java b/core/src/com/google/inject/internal/MoreTypes.java
index bd0f838..12a7625 100644
--- a/core/src/com/google/inject/internal/MoreTypes.java
+++ b/core/src/com/google/inject/internal/MoreTypes.java
@@ -329,13 +329,7 @@
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;
- checkArgument(ownerType != null || rawTypeAsClass.getEnclosingClass() == null,
- "No owner type for enclosed %s", rawType);
- checkArgument(ownerType == null || rawTypeAsClass.getEnclosingClass() != null,
- "Owner type for unenclosed %s", rawType);
- }
+ ensureOwnerType(ownerType, rawType);
this.ownerType = ownerType == null ? null : canonicalize(ownerType);
this.rawType = canonicalize(rawType);
@@ -403,6 +397,16 @@
return stringBuilder.append(">").toString();
}
+ private static void ensureOwnerType(Type ownerType, Type rawType) {
+ if (rawType instanceof Class<?>) {
+ Class rawTypeAsClass = (Class) rawType;
+ checkArgument(ownerType != null || rawTypeAsClass.getEnclosingClass() == null,
+ "No owner type for enclosed %s", rawType);
+ checkArgument(ownerType == null || rawTypeAsClass.getEnclosingClass() != null,
+ "Owner type for unenclosed %s", rawType);
+ }
+ }
+
private static final long serialVersionUID = 0;
}