-
Notifications
You must be signed in to change notification settings - Fork 238
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
Fix #986 #1072
Open
manoelcampos
wants to merge
16
commits into
vojtechhabarta:main
Choose a base branch
from
manoelcampos:issue-986
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix #986 #1072
Conversation
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
Signed-off-by: Manoel Campos <[email protected]>
of ignoring nested generic type arguments. Considering a class such as List<List<Double>>, the generic type argument is List<Double>, but it was being parsed as List. - Adds toString(), equals() and hashCode() to Settings.GenericName inner class to make tests easier. Signed-off-by: Manoel Campos <[email protected]>
Use Assertions static import to simplify code Signed-off-by: Manoel Campos <[email protected]>
- Makes Settings.loadPrimitiveOrRegularClass protected to allow it to be tested Signed-off-by: Manoel Campos <[email protected]>
of ignoring the generic type argument and mapping every type that matches the raw class name to the mapped type. For instance, if we configure the plugin to map List<BigDecimal> to number[], it will map every List attribute to the target type. Even a List<String> will be mapped to number[] in this example. Signed-off-by: Manoel Campos <[email protected]>
…s instead of null - Storing null required always checking that to avoid NullPointerException, making the code dirty. - Replacing the value by an empty list removes those checks and makes it easier to implement the fix for the current issue. Signed-off-by: Manoel Campos <[email protected]>
That enables the correct parse of nested generic type arguments. If we have a type such as Class<T1<T2>, T3>, type arguments won't be parsed as T1 and T3 anymore, but as T1<T2> and T3. The Class[T1[T2], T3] syntax also works. Signed-off-by: Manoel Campos <[email protected]>
…eric type arguments The classLoader.loadClass() method requires the raw class name to find the class to load (that is the class name without the generic type arguments). The Settings.loadPrimitiveOrRegularClass now removes the generic parameters from the class name to load the class correctly. Signed-off-by: Manoel Campos <[email protected]>
…pe that matches the class raw name, ignoring the generic parameters - If we had a mapping List<BigInteger>:number[], every kind of list was being mapped to number[], even List<String> and any other kind of list. - Update the CustomMappingTypeProcessor.processType() to filter by the generic type arguments after checking the raw class name, to confirm the exact type (such as List<BigInteger> instead of just List) before mapping. - The previous change in the default value of Settings.GenericName.typeParameters to an empty list makes the filter easier and NPE-safe. Signed-off-by: Manoel Campos <[email protected]>
…d chars Since now the class CustomMappingTypeProcessor correctly extracts each generic type argument (even nested ones), a generic type can have some special chars. For instance, in a type such as java.util.List<java.util.List<String>>, the generic type argument is java.util.List<String>, which has the characters: . < > Previously, the class was indicating this as an invalid identifier for the type. But this is a valid one, even for Java or TypeScript. Signed-off-by: Manoel Campos <[email protected]>
…st simpler. Signed-off-by: Manoel Campos <[email protected]>
…n't know how to make the test work yet. Signed-off-by: Manoel Campos <[email protected]>
Signed-off-by: Manoel Campos <[email protected]>
It doen't change behaviour. Signed-off-by: Manoel Campos <[email protected]>
manoelcampos
force-pushed
the
issue-986
branch
from
November 9, 2024 01:16
4e70908
to
06f534f
Compare
Signed-off-by: Manoel Campos <[email protected]>
to include class names that use nested generic types and check if the correct class/interface reference (type reference) is loaded. Signed-off-by: Manoel Campos <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #986
List<List<Double>>
, the generic type argument isList<Double>
, but it was being parsed just asList
.List<BigDecimal>
tonumber[]
, it was mapping every List attribute to the target type. Even aList<String>
was being mapped tonumber[]
in this example.Class<T1<T2>, T3>
, type arguments won't be parsed asT1
andT3
anymore, but asT1<T2>
andT3
. TheClass[T1[T2], T3]
syntax also works.** If we had a mapping
List<BigInteger>:number[]
, every kind of list was being mapped tonumber[]
,even
List<String>
and any other kind of list.** Update the CustomMappingTypeProcessor.processType() to filter by the generic type arguments
after checking the raw class name, to confirm the exact type (such as
List<BigInteger>
instead of justList
)before mapping.
** The previous change in the default value of Settings.GenericName.typeParameters to an empty list
makes the filter easier and NPE-safe.
java.util.List<java.util.List<String>>
, the generic type argument isjava.util.List<String>
, which has the characters:.
<
>
. Previously, the class was indicating this as an invalid identifier for the type. But this is a valid one, even for Java or TypeScript.