-
Notifications
You must be signed in to change notification settings - Fork 100
[599] Add better support for resolution of wildcard types. #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
|
@@ -233,7 +233,7 @@ private ModelDeserializer<JsonParser> createObjectDeserializer(LinkedList<Type> | |
if (creatorModel.getCustomization().isRequired()) { | ||
defaultCreatorValues.put(parameterName, new RequiredCreatorParameter(parameterName)); | ||
} else { | ||
Class<?> rawParamType = ReflectionUtils.getRawType(creatorModel.getType()); | ||
Class<?> rawParamType = ReflectionUtils.getOptionalRawType(creatorModel.getType()).orElse(Object.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure if this is the correct place to fix this. I did attempt to fix it by defaulting to |
||
defaultCreatorValues.put(parameterName, DEFAULT_CREATOR_VALUES.getOrDefault(rawParamType, NULL_PROVIDER)); | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/org/eclipse/yasson/defaultmapping/generics/model/CollectionContainer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2025 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.defaultmapping.generics.model; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class CollectionContainer { | ||
|
||
private CollectionWrapper<CollectionElement<?>> collection; | ||
|
||
public CollectionWrapper<CollectionElement<?>> getCollection() { | ||
return collection; | ||
} | ||
|
||
public void setCollection(final CollectionWrapper<CollectionElement<?>> collection) { | ||
this.collection = collection; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (!(obj instanceof CollectionContainer)) { | ||
return false; | ||
} | ||
final CollectionContainer other = (CollectionContainer) obj; | ||
final Collection<CollectionElement<?>> thisCollection = collection.getCollection(); | ||
final Collection<CollectionElement<?>> otherCollection = other.collection.getCollection(); | ||
if (thisCollection == null && otherCollection == null) { | ||
return true; | ||
} | ||
if (thisCollection == null || otherCollection == null) { | ||
return false; | ||
} | ||
return thisCollection.containsAll(otherCollection) && otherCollection.containsAll(thisCollection); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(collection); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/test/java/org/eclipse/yasson/defaultmapping/generics/model/CollectionElement.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2025 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.defaultmapping.generics.model; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class CollectionElement<T> { | ||
|
||
private T wrapped; | ||
|
||
public T getWrapped() { | ||
return wrapped; | ||
} | ||
|
||
public void setWrapped(T wrapped) { | ||
this.wrapped = wrapped; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(wrapped); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof CollectionElement)) { | ||
return false; | ||
} | ||
final CollectionElement<?> other = (CollectionElement<?>) obj; | ||
return Objects.equals(wrapped, other.wrapped); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/test/java/org/eclipse/yasson/defaultmapping/generics/model/ConstructorContainer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2025 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.defaultmapping.generics.model; | ||
|
||
import java.util.Objects; | ||
|
||
import jakarta.json.bind.annotation.JsonbCreator; | ||
import jakarta.json.bind.annotation.JsonbProperty; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class ConstructorContainer<T> { | ||
|
||
private final T value; | ||
|
||
@JsonbCreator | ||
public ConstructorContainer(@JsonbProperty("value") final T value) { | ||
this.value = value; | ||
} | ||
|
||
public T getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ConstructorContainer[value=" + value + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(value); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof ConstructorContainer)) { | ||
return false; | ||
} | ||
final ConstructorContainer<?> other = (ConstructorContainer<?>) obj; | ||
return Objects.equals(value, other.value); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/test/java/org/eclipse/yasson/defaultmapping/generics/model/StaticCreatorContainer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2025 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.defaultmapping.generics.model; | ||
|
||
import java.util.Objects; | ||
|
||
import jakarta.json.bind.annotation.JsonbCreator; | ||
import jakarta.json.bind.annotation.JsonbProperty; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class StaticCreatorContainer<T> { | ||
private final T value; | ||
|
||
private StaticCreatorContainer(T value) { | ||
this.value = value; | ||
} | ||
|
||
@JsonbCreator | ||
public static <T> StaticCreatorContainer<T> create(@JsonbProperty("value") final T value) { | ||
return new StaticCreatorContainer<>(value); | ||
} | ||
|
||
public T getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "StaticCreatorContainer[value=" + value + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(value); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof StaticCreatorContainer)) { | ||
return false; | ||
} | ||
final StaticCreatorContainer<?> other = (StaticCreatorContainer<?>) obj; | ||
return Objects.equals(value, other.value); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.