Skip to content
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
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Fix #986 #1072

wants to merge 14 commits into from

Commits on Nov 9, 2024

  1. Adds files generated during test execution to .gitignore

    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    7a51c27 View commit details
    Browse the repository at this point in the history
  2. Adds test in SettingsTest to confirm the issue

    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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    909fb17 View commit details
    Browse the repository at this point in the history
  3. Refactor SettingsTest

    Use Assertions static import to simplify code
    
    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    8ca83d2 View commit details
    Browse the repository at this point in the history
  4. Add SettingsTest.testLoadPrimitiveOrRegularClass

    - Makes Settings.loadPrimitiveOrRegularClass protected to allow it to be tested
    
    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    5a15007 View commit details
    Browse the repository at this point in the history
  5. Adds new tests to CustomTypeMappingTest to confirm the issue

    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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    a209962 View commit details
    Browse the repository at this point in the history
  6. Stores an empty list by default in Settings.GenericName.typeParameter…

    …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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    e3f46d4 View commit details
    Browse the repository at this point in the history
  7. Updates the regex in Settings.parseGenericName

    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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    bc9f2e1 View commit details
    Browse the repository at this point in the history
  8. Fix the issue of custom type mapping not loading a class that has gen…

    …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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    125ec31 View commit details
    Browse the repository at this point in the history
  9. Fix the issue in CustomMappingTypeProcessor that was mapping every ty…

    …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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    79f83da View commit details
    Browse the repository at this point in the history
  10. Update the ModelCompiler.isValidIdentifierPart() to include more vali…

    …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 <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    3f9878c View commit details
    Browse the repository at this point in the history
  11. Refactor GenericsResolverTest add Assertions static import to make te…

    …st simpler.
    
    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    1540086 View commit details
    Browse the repository at this point in the history
  12. Add tests for the new GenericsResolver.typeParameterNameList but I do…

    …n't know how to make the test work yet.
    
    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    a5b6c3b View commit details
    Browse the repository at this point in the history
  13. Update Settings.loadPrimitiveOrRegularClass comment

    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    e5f5404 View commit details
    Browse the repository at this point in the history
  14. Update Settings.loadPrimitiveOrRegularClass to use positive condition

    It doen't change behaviour.
    
    Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
    manoelcampos committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    06f534f View commit details
    Browse the repository at this point in the history