Skip to content

Commit

Permalink
Merge pull request #349 from avaje/feature/tidy-TypeExtendsReader
Browse files Browse the repository at this point in the history
No effective change - tidy TypeExtendsReader
  • Loading branch information
rbygrave authored May 21, 2023
2 parents 40492a3 + 5015e56 commit 30c508c
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private boolean autoProvide() {
&& !isController();
}

@SuppressWarnings("unchecked")
private boolean isController() {
try {
return baseType.getAnnotation((Class<Annotation>) Class.forName(Constants.CONTROLLER)) != null;
Expand Down Expand Up @@ -169,15 +170,14 @@ private void addSuperType(TypeElement element, TypeMirror mirror) {
if (!JAVA_LANG_OBJECT.equals(fullName) && !JAVA_LANG_RECORD.equals(fullName)) {
final String type = Util.unwrapProvider(fullName);
if (isPublic(element)) {
final var genericType= GenericType.parse(type);
final var genericType = GenericType.parse(type);
// check if any unknown generic types are in the parameters (T,T2, etc.)
final var knownType =
genericType.params().stream()
.flatMap(g -> Stream.concat(Stream.of(g), g.params().stream()))
.noneMatch(g -> element(g.mainType()) == null);
genericType.params().stream()
.flatMap(g -> Stream.concat(Stream.of(g), g.params().stream()))
.noneMatch(g -> element(g.mainType()) == null);

extendsTypes.add(knownType ? type : genericType.topType());

extendsInjection.read(element);
}

Expand All @@ -198,7 +198,10 @@ private void readInterfaces(TypeElement type) {
private void readInterfacesOf(TypeMirror anInterface) {
final String rawType = Util.unwrapProvider(anInterface.toString());
if (JAVA_LANG_OBJECT.equals(rawType)) {
} else if (rawType.indexOf('.') == -1) {
// we can stop
return;
}
if (rawType.indexOf('.') == -1) {
logWarn("skip when no package on interface " + rawType);
} else if (Constants.AUTO_CLOSEABLE.equals(rawType) || Constants.IO_CLOSEABLE.equals(rawType)) {
closeable = true;
Expand All @@ -214,13 +217,12 @@ private void readInterfacesOf(TypeMirror anInterface) {
}
// check if any unknown generic types are in the parameters (T,T2, etc.)
final var knownType =
genericType.params().stream()
.flatMap(g -> Stream.concat(Stream.of(g), g.params().stream()))
.noneMatch(g -> element(g.mainType()) == null);
genericType.params().stream()
.flatMap(g -> Stream.concat(Stream.of(g), g.params().stream()))
.noneMatch(g -> element(g.mainType()) == null);

interfaceTypes.add(knownType ? rawType : GenericType.removeParameter(rawType));
if (!rawType.startsWith("java.lang.")) {

for (final TypeMirror supertype : types().directSupertypes(anInterface)) {
readInterfacesOf(supertype);
}
Expand Down

0 comments on commit 30c508c

Please sign in to comment.