Rename withValue to with, add Javadoc

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/66bbf4dd
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/66bbf4dd
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/66bbf4dd

Branch: refs/heads/master
Commit: 66bbf4ddfd94834817bf83a6dc06fb89fae37569
Parents: d3a0641
Author: Mikael Ståldal <mikael.stal...@magine.com>
Authored: Fri Oct 23 15:18:16 2015 +0200
Committer: Mikael Ståldal <mikael.stal...@magine.com>
Committed: Fri Oct 23 15:18:16 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/message/MapMessage.java   | 8 +++++++-
 .../apache/logging/log4j/message/StructuredDataMessage.java | 9 ++++++++-
 .../org/apache/logging/log4j/message/MapMessageTest.java    | 4 ++--
 .../logging/log4j/message/StructuredDataMessageTest.java    | 6 +++---
 4 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66bbf4dd/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
----------------------------------------------------------------------
diff --git 
a/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java 
b/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
index 1012d0e..b113ed5 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
@@ -109,7 +109,13 @@ public class MapMessage implements MultiformatMessage {
         data.clear();
     }
 
-    public MapMessage withValue(final String key, final String value) {
+    /**
+     * Add an item to the data Map in fluent style.
+     * @param key The name of the data item.
+     * @param value The value of the data item.
+     * @return {@code this}
+     */
+    public MapMessage with(final String key, final String value) {
         put(key, value);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66bbf4dd/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
----------------------------------------------------------------------
diff --git 
a/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
 
b/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
index abacce2..f29732e 100644
--- 
a/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
+++ 
b/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
@@ -130,7 +130,14 @@ public class StructuredDataMessage extends MapMessage {
 
     }
 
-    public StructuredDataMessage withValue(final String key, final String 
value) {
+    /**
+     * Add an item to the data Map in fluent style.
+     * @param key The name of the data item.
+     * @param value The value of the data item.
+     * @return {@code this}
+     */
+    @Override
+    public StructuredDataMessage with(final String key, final String value) {
         put(key, value);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66bbf4dd/log4j-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java 
b/log4j-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
index 7f43027..e7bef75 100644
--- 
a/log4j-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
+++ 
b/log4j-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
@@ -40,8 +40,8 @@ public class MapMessageTest {
     public void testBuilder() {
         final String testMsg = "Test message {}";
         final MapMessage msg = new MapMessage()
-                .withValue("message", testMsg)
-                .withValue("project", "Log4j");
+                .with("message", testMsg)
+                .with("project", "Log4j");
         final String result = msg.getFormattedMessage();
         final String expected = "message=\"Test message {}\" 
project=\"Log4j\"";
         assertEquals(expected, result);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66bbf4dd/log4j-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
 
b/log4j-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
index ce9ad9b..47116f2 100644
--- 
a/log4j-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
+++ 
b/log4j-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
@@ -41,9 +41,9 @@ public class StructuredDataMessageTest {
     public void testBuilder() {
         final String testMsg = "Test message {}";
         final StructuredDataMessage msg = new 
StructuredDataMessage("MsgId@12345", testMsg, "Alert")
-                .withValue("message", testMsg)
-                .withValue("project", "Log4j")
-                .withValue("memo", "This is a very long test memo to prevent 
regression of LOG4J2-114");
+                .with("message", testMsg)
+                .with("project", "Log4j")
+                .with("memo", "This is a very long test memo to prevent 
regression of LOG4J2-114");
         final String result = msg.getFormattedMessage();
         final String expected = "Alert [MsgId@12345 memo=\"This is a very long 
test memo to prevent regression of LOG4J2-114\" message=\"Test message {}\" 
project=\"Log4j\"] Test message {}";
         assertEquals(expected, result);

Reply via email to