You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2020/12/06 13:51:21 UTC

[tapestry-5] branch master updated (60ac57a -> b5b2e74)

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

thiagohp pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git.


    from 60ac57a  Fixing TimeIntervalDemo
     new 1834d67  TAP5-2645: Java Time API type coercers (by Ben Weidig)
     new b5b2e74  TAP5-2651: TypeCoercer favoring exact match coercions

The 2 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:
 .../commons/internal/services/TypeCoercerImpl.java | 12 +++++
 .../tapestry5/ioc/modules/TapestryIOCModule.java   | 52 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)


[tapestry-5] 01/02: TAP5-2645: Java Time API type coercers (by Ben Weidig)

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

thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 1834d6734cd3e12f8947ccc79d0e7a626e4eaadb
Author: Thiago H. de Paula Figueiredo <th...@arsmachina.com.br>
AuthorDate: Sun Dec 6 09:53:08 2020 -0300

    TAP5-2645: Java Time API type coercers (by Ben Weidig)
---
 .../tapestry5/ioc/modules/TapestryIOCModule.java   | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
index ac8cca8..b6067c2 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
@@ -261,6 +261,58 @@ public final class TapestryIOCModule
     }
     
     /**
+     * Contributes coercions to and from Java Time API (JSR 310) classes.
+     * <ul>
+     * <li>java.time.Year to Integer</li>
+     * <li>Integer to java.time.Year</li>
+     * <li>java.time.Month to Integer</li>
+     * <li>Integer to Java.time.Month</li>
+     * <li>java.time.Month to String</li>
+     * <li>String to java.time.Month</li>
+     * <li>String to java.time.YearMonth</li>
+     * <li>java.time.YearMonth to java.time.Year</li>
+     * <li>java.time.YearMonth to java.time.Month</li>
+     * <li>String to java.time.MonthDay</li>
+     * <li>java.time.MonthDay to java.time.Month</li>
+     * <li>java.time.DayOfWeek to Integer</li>
+     * <li>Integer to java.time.DayOfWeek</li>
+     * <li>java.time.DayOfWeek to String</li>
+     * <li>String to java.time.DayOfWeek</li>
+     * <li>java.time.LocalDate to java.time.Instant</li>
+     * <li>java.time.Instant to java.time.LocalDate</li>
+     * <li>String to java.time.LocalDate</li>
+     * <li>java.time.LocalDate to java.time.YearMonth</li>
+     * <li>java.time.LocalDate to java.time.MonthDay</li>
+     * <li>java.time.LocalTime to Long</li>
+     * <li>Long to java.time.LocalTime</li>
+     * <li>String to java.time.LocalDateTime</li>
+     * <li>java.time.LocalDateTime to java.time.Instant</li>
+     * <li>java.time.Instant to LocalDateTime</li>
+     * <li>java.time.LocalDateTime to java.time.LocalDate</li>
+     * <li>String to java.time.OffsetDateTime</li>
+     * <li>java.time.OffsetDateTime to java.time.Instant</li>
+     * <li>java.time.Instant to java.time.OffsetDateTime</li>
+     * <li>String to java.time.ZoneId</li>
+     * <li>String to java.time.ZoneOffset</li>
+     * <li>String to java.time.ZonedDateTime</li>
+     * <li>java.time.ZonedDateTime to java.time.Instant</li>
+     * <li>java.time.ZonedDateTime to java.time.ZoneId</li>
+     * <li>java.time.Instant to Long</li>
+     * <li>Long to java.time.Instant</li>
+     * <li>java.time.Instant to java.util.Date</li>
+     * <li>java.util.Date to java.time.Instant</li>
+     * <li>java.time.Duration to Long</li>
+     * <li>Long to java.time.Duration</li>
+     * <li>String to java.time.Period</li>
+     * </ul>
+     */
+    @Contribute(TypeCoercer.class)
+    public static void provideJSR10TypeCoercions(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration)
+    {
+        BasicTypeCoercions.provideJSR310TypeCoercions(configuration);
+    }
+    
+    /**
      * <dl>
      * <dt>SystemProperties</dt>
      * <dd>Exposes JVM System properties as symbols (currently case-sensitive)</dd>


[tapestry-5] 02/02: TAP5-2651: TypeCoercer favoring exact match coercions

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

thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit b5b2e74bc0460a326efbb6814d7583078588fa11
Author: Thiago H. de Paula Figueiredo <th...@arsmachina.com.br>
AuthorDate: Sun Dec 6 10:50:59 2020 -0300

    TAP5-2651: TypeCoercer favoring exact match coercions
    
    over indirect/intermediate ones
---
 .../tapestry5/commons/internal/services/TypeCoercerImpl.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/commons/src/main/java/org/apache/tapestry5/commons/internal/services/TypeCoercerImpl.java b/commons/src/main/java/org/apache/tapestry5/commons/internal/services/TypeCoercerImpl.java
index 681fa17..b89eb64 100644
--- a/commons/src/main/java/org/apache/tapestry5/commons/internal/services/TypeCoercerImpl.java
+++ b/commons/src/main/java/org/apache/tapestry5/commons/internal/services/TypeCoercerImpl.java
@@ -17,6 +17,7 @@ import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.WeakHashMap;
 
@@ -286,6 +287,17 @@ public class TypeCoercerImpl extends LockSupport implements TypeCoercer
         {
             return searchForNullCoercion(targetType);
         }
+        
+        // Trying to find exact match.
+        Optional<CoercionTuple> maybeTuple = 
+                getTuples(sourceType, targetType).stream()
+                    .filter((t) -> sourceType.equals(t.getSourceType()) && 
+                            targetType.equals(t.getTargetType())).findFirst();
+        
+        if (maybeTuple.isPresent())
+        {
+            return maybeTuple.get().getCoercion();
+        }
 
         // These are instance variables because this method may be called concurrently.
         // On a true race, we may go to the work of seeking out and/or fabricating