Skip to content

2329 Optimization: Caching DateTimeFormatter instances#2416

Closed
eforest wants to merge 1 commit intomapstruct:masterfrom
eforest:2329-squashed
Closed

2329 Optimization: Caching DateTimeFormatter instances#2416
eforest wants to merge 1 commit intomapstruct:masterfrom
eforest:2329-squashed

Conversation

@eforest
Copy link
Contributor

@eforest eforest commented Apr 15, 2021

  • GetDateTimeFormatterField
    ** a FieldReference that creates DateTimeFormatters
    for given dateFormat as mapper fields
    ** variableName is created using given dateFormat

  • AbstractJavaTimeToStringConversion
    provides GetDateTimeFormatterField as required helper field
    using DateTimeFormatter instances provided as mapper fields
    by GetDateTimeFormatterField

  • ConversionProvider
    might provide supporting fields directly

  • Refactoring
    moved/renamed BuiltInFieldReference, BuiltInConstuctorFragment to
    package model/common

  • MappingBuilderContext provides access to mapper support fields
    (that are independent of mapper methods)

  • MappingResolverImpl / MapperCreationProcessor
    process supporting fields provided by ConversionProvider

  • HelperMethod
    ** extended to supply additional template parameters to
    be more flexible in freemarker templates
    ** extended to support mapper field reference / constructor fragment

  • SupportingMappingMethod
    ** provide templateParameters to freemarker
    ** hashCode/equals base on name property instead of template name,
    as we use one specific template multiple times with different
    parameters generating multiple methods
    ** #getSafeField extracted to SupportingField

  • SupportingField
    ** removed hashCode/equals based on template name,
    as we use one specific template multiple times with different
    parameters generating multiple methods
    (superclass equals/hashcode is fine for that)
    ** added support for template parameters to be more flexible when
    compiling templates

  • Tests to verify DateTimeFormatter instance field creation

Fixes #2329

* GetDateTimeFormatterField
** a FieldReference that creates DateTimeFormatters
   for given dateFormat as mapper fields
** variableName is created using given dateFormat

* AbstractJavaTimeToStringConversion
  provides GetDateTimeFormatterField as required helper field
  using DateTimeFormatter instances provided as mapper fields
  by GetDateTimeFormatterField

* ConversionProvider
  might provide supporting fields directly

* Refactoring
  moved/renamed BuiltInFieldReference, BuiltInConstuctorFragment to
package model/common

* MappingBuilderContext provides access to mapper support fields
  (that are independent of mapper methods)

* MappingResolverImpl / MapperCreationProcessor
  process supporting fields provided by ConversionProvider

* HelperMethod
** extended to supply additional template parameters to
   be more flexible in freemarker templates
** extended to support mapper field reference / constructor fragment

* SupportingMappingMethod
** provide templateParameters to freemarker
** hashCode/equals base on name property instead of template name,
   as we use one specific template multiple times with different
   parameters generating multiple methods
** #getSafeField extracted to SupportingField

* SupportingField
** removed hashCode/equals based on template name,
   as we use one specific template multiple times with different
   parameters generating multiple methods
   (superclass equals/hashcode is fine for that)
** added support for template parameters to be more flexible when
  compiling templates

* Tests to verify DateTimeFormatter instance field creation
Copy link

@FuncGuy FuncGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@filiphr
Copy link
Member

filiphr commented May 16, 2021

Thanks for the PR @eforest. Manually merged it with some small changes in a6ac4f3.

@filiphr filiphr closed this May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimization: Make java.time.format.DateTimeFormatter instances final members

3 participants