You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/07/07 14:16:44 UTC

[causeway] branch spring6 updated (312e373d34 -> 127e4c7c9b)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch spring6
in repository https://gitbox.apache.org/repos/asf/causeway.git


    from 312e373d34 Merge remote-tracking branch 'origin/master' into spring6
     add 21914c1ecc CAUSEWAY-3404: YamlUtils: allow for LoaderOptions to be customized
     new 127e4c7c9b CAUSEWAY-3404: YamlUtils: allow for LoaderOptions to be customized

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/causeway/commons/io/YamlUtils.java  | 49 ++++++++++++++--------
 1 file changed, 31 insertions(+), 18 deletions(-)


[causeway] 01/01: CAUSEWAY-3404: YamlUtils: allow for LoaderOptions to be customized

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch spring6
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 127e4c7c9b06d4a0309c444c2258987bf5b563c9
Merge: 312e373d34 21914c1ecc
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Jul 7 16:16:39 2023 +0200

    CAUSEWAY-3404: YamlUtils: allow for LoaderOptions to be customized

 .../org/apache/causeway/commons/io/YamlUtils.java  | 49 ++++++++++++++--------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --cc commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
index ef7ebe4db2,3ffac618eb..d279c91612
--- a/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
@@@ -131,19 -122,24 +137,26 @@@ public class YamlUtils 
  
      private Yaml createMapper(
              final Class<?> mappedType,
-             final YamlUtils.YamlCustomizer ... customizers) {
-         var options = new DumperOptions();
-         options.setIndent(2);
-         options.setLineBreak(LineBreak.UNIX); // fixated for consistency
+             final Can<YamlUtils.YamlLoadCustomizer> loadCustomizers,
+             final Can<YamlUtils.YamlDumpCustomizer> dumpCustomizers) {
+         var dumperOptions = new DumperOptions();
+         dumperOptions.setIndent(2);
+         dumperOptions.setLineBreak(LineBreak.UNIX); // fixated for consistency
          //options.setPrettyFlow(true);
          //options.setDefaultFlowStyle(FlowStyle.BLOCK);
-         for(YamlUtils.YamlCustomizer customizer : customizers) {
-             options = Optional.ofNullable(customizer.apply(options))
-                     .orElse(options);
+         for(YamlUtils.YamlDumpCustomizer customizer : dumpCustomizers) {
+             dumperOptions = Optional.ofNullable(customizer.apply(dumperOptions))
+                     .orElse(dumperOptions);
          }
-         var presenter = new Representer(options);
++        var presenter = new Representer(dumperOptions);
 +        presenter.setPropertyUtils(new PropertyUtils2());
-         var mapper = new Yaml(new Constructor(mappedType, new LoaderOptions()), presenter);
+ 
+         var loaderOptions = new LoaderOptions();
+         for(YamlUtils.YamlLoadCustomizer customizer : loadCustomizers) {
+             loaderOptions = Optional.ofNullable(customizer.apply(loaderOptions))
+                     .orElse(loaderOptions);
+         }
 -        var mapper = new Yaml(new Constructor(mappedType), new Representer(dumperOptions), dumperOptions, loaderOptions);
++        var mapper = new Yaml(new Constructor(mappedType, loaderOptions), presenter, dumperOptions, loaderOptions);
          return mapper;
      }