[jackson-annotations] 74/207: Improve handling of JsonFormat.value a bit, to make it easier to manipulate

Timo Aaltonen tjaalton at moszumanska.debian.org
Sat Sep 6 13:55:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-annotations.

commit 8b42a2f3dd9d27957a7f6c83057a5ac0f793b047
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date:   Thu Jul 19 19:14:29 2012 -0700

    Improve handling of JsonFormat.value a bit, to make it easier to manipulate
---
 .../fasterxml/jackson/annotation/JsonFormat.java   | 54 +++++++++++++++++-----
 1 file changed, 43 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java b/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java
index 620ff0e..a4bd29b 100644
--- a/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java
+++ b/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java
@@ -178,23 +178,55 @@ public @interface JsonFormat
 
         public Value(JsonFormat ann) {
             this(ann.pattern(), ann.shape(), ann.locale(), ann.timezone());
-                    
         }
 
         public Value(String p, Shape sh, String localeStr, String tzStr)
         {
+            this(p, sh
+                    ,(localeStr == null || localeStr.length() == 0 || DEFAULT_LOCALE.equals(localeStr)) ?
+                            null : new Locale(localeStr)
+                    ,(tzStr == null || tzStr.length() == 0 || DEFAULT_TIMEZONE.equals(tzStr)) ?
+                            null : TimeZone.getTimeZone(tzStr)
+            );
+        }
+
+        /**
+         * @since 2.1
+         */
+        public Value(String p, Shape sh, Locale l, TimeZone tz)
+        {
             pattern = p;
             shape = sh;
-            if (localeStr == null || localeStr.length() == 0 || DEFAULT_LOCALE.equals(localeStr)) {
-                locale = null;
-            } else {
-                locale = new Locale(localeStr);
-            }
-            if (tzStr == null || tzStr.length() == 0 || DEFAULT_TIMEZONE.equals(tzStr)) {
-                timezone = null;
-            } else {
-                timezone = TimeZone.getTimeZone(tzStr);
-            }
+            locale = l;
+            timezone = tz;
+        }
+
+        /**
+         * @since 2.1
+         */
+        public Value withPattern(String p) {
+            return new Value(p, shape, locale, timezone);
+        }
+
+        /**
+         * @since 2.1
+         */
+        public Value withShape(Shape s) {
+            return new Value(pattern, s, locale, timezone);
+        }
+
+        /**
+         * @since 2.1
+         */
+        public Value withLocale(Locale l) {
+            return new Value(pattern, shape, l, timezone);
+        }
+
+        /**
+         * @since 2.1
+         */
+        public Value withTimeZone(TimeZone tz) {
+            return new Value(pattern, shape, locale, tz);
         }
         
         public String getPattern() { return pattern; }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-annotations.git



More information about the pkg-java-commits mailing list