Skip to content

Commit

Permalink
Refactor extract InterfaceResolvingType.of
Browse files Browse the repository at this point in the history
  • Loading branch information
kindlich committed Aug 31, 2024
1 parent 411a8b7 commit a8b7a13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ public ResolvingType resolve(TypeID[] typeArguments) {
resolved = new SubclassResolvingType(superResolved, resolved, superType);
}

if (interfaces.isEmpty()) {
return resolved;
} else {
return new InterfaceResolvingType(resolved, interfaces);
}
return InterfaceResolvingType.of(resolved, interfaces);
}

protected void resolveAdditional(TypeID type, MemberSet.Builder members, GenericMapper mapper) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ public class InterfaceResolvingType implements ResolvingType {
private final ResolvingType baseType;
private final Collection<TypeID> implementedInterfaces;

public InterfaceResolvingType(ResolvingType baseType, Collection<TypeID> implementedInterfaces) {
public static ResolvingType of(ResolvingType baseType, Collection<TypeID> implementedInterfaces) {
if(implementedInterfaces.isEmpty()){
return baseType;
}

return new InterfaceResolvingType(baseType, implementedInterfaces);
}

private InterfaceResolvingType(ResolvingType baseType, Collection<TypeID> implementedInterfaces) {
this.baseType = baseType;
this.implementedInterfaces = implementedInterfaces;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public ResolvingType resolve(TypeID[] typeArguments) {
}

Collection<TypeID> interfaces = getInterfaces(typeArguments);
if (!interfaces.isEmpty()) {
resolved = new InterfaceResolvingType(resolved, interfaces);
}

return resolved;
return InterfaceResolvingType.of(resolved, interfaces);
}

@Override
Expand Down

0 comments on commit a8b7a13

Please sign in to comment.