-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[599] Add better support for resolution of wildcard types.
Signed-off-by: James R. Perkins <[email protected]>
- Loading branch information
Showing
7 changed files
with
272 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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); | ||
} | ||
|
||
} |