Skip to content

Commit e82a63c

Browse files
authored
Merge pull request #463 from avaje/feature/rename-types
Refactor rename Types -> RawType and make internal
2 parents 4cbe4b5 + f609b0e commit e82a63c

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

inject/src/main/java/io/avaje/inject/spi/Types.java renamed to inject/src/main/java/io/avaje/inject/spi/RawType.java

+5-18
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,15 @@
2020
/**
2121
* Factory methods for types.
2222
*/
23-
public class Types {
23+
final class RawType {
2424

25-
private Types() {
25+
private RawType() {
2626
}
2727

28-
// /** Returns an array type whose elements are all instances of {@code componentType}. */
29-
// public static GenericArrayType arrayOf(Type elementType) {
30-
// return GenericTypeUtil.arrayOf(elementType);
31-
// }
32-
//
33-
// /**
34-
// * Returns a new parameterized type, applying {@code typeArguments} to {@code rawType}. Use this
35-
// * method if {@code rawType} is not enclosed in another type.
36-
// */
37-
// public static ParameterizedType parameterizedType(Type rawType, Type... typeArguments) {
38-
// return GenericTypeUtil.newParameterizedType(rawType, typeArguments);
39-
// }
40-
4128
/**
4229
* Return the raw type for the given potentially generic type.
4330
*/
44-
public static Class<?> rawType(Type type) {
31+
static Class<?> of(Type type) {
4532
if (type instanceof Class<?>) {
4633
// type is a normal class.
4734
return (Class<?>) type;
@@ -53,13 +40,13 @@ public static Class<?> rawType(Type type) {
5340

5441
} else if (type instanceof GenericArrayType) {
5542
Type componentType = ((GenericArrayType) type).getGenericComponentType();
56-
return Array.newInstance(rawType(componentType), 0).getClass();
43+
return Array.newInstance(of(componentType), 0).getClass();
5744

5845
} else if (type instanceof TypeVariable) {
5946
return Object.class;
6047

6148
} else if (type instanceof WildcardType) {
62-
return rawType(((WildcardType) type).getUpperBounds()[0]);
49+
return of(((WildcardType) type).getUpperBounds()[0]);
6350

6451
} else {
6552
String className = type == null ? "null" : type.getClass().getName();

inject/src/main/java/io/avaje/inject/spi/SuppliedBean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private static final class ForType extends SuppliedBean {
151151
@Override
152152
public Object source() {
153153
if (source == null) {
154-
source = Mockito.mock(Types.rawType(classType));
154+
source = Mockito.mock(RawType.of(classType));
155155
}
156156
return source;
157157
}

0 commit comments

Comments
 (0)