Skip to content

Commit

Permalink
#2436 - formatting and minor changes as per review.
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinp97 committed Sep 24, 2023
1 parent 5c0ea74 commit 263a918
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gson/src/main/java/com/google/gson/GsonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
|| typeAdapter instanceof InstanceCreator<?>
|| typeAdapter instanceof TypeAdapter<?>);

if(isTypeObjectOrJsonElement(type)){
if (isTypeObjectOrJsonElement(type)){
throw new IllegalArgumentException("Cannot override built-in adapter for " + type);
}

Expand All @@ -695,9 +695,9 @@ public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
}

private boolean isTypeObjectOrJsonElement(Type type) {
return (!(type instanceof ParameterizedType) &&
return type instanceof Class &&
(type == Object.class
|| (type instanceof Class && JsonElement.class.isAssignableFrom((Class<?>) type))));
|| JsonElement.class.isAssignableFrom((Class<?>) type));
}

/**
Expand Down

0 comments on commit 263a918

Please sign in to comment.