Repository: logging-log4j2 Updated Branches: refs/heads/GenericMapMessageSimple ec27fe7b3 -> 2e42ea8bd
Order the new methods in AB order and add @since 2.9 tags. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2e42ea8b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2e42ea8b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2e42ea8b Branch: refs/heads/GenericMapMessageSimple Commit: 2e42ea8bd11669a6a42f3b854ba9e68ad8f631e3 Parents: ec27fe7 Author: Gary Gregory <[email protected]> Authored: Sun Jun 4 09:36:07 2017 -0700 Committer: Gary Gregory <[email protected]> Committed: Sun Jun 4 09:36:07 2017 -0700 ---------------------------------------------------------------------- .../logging/log4j/message/MapMessage.java | 378 ++++++++++--------- .../log4j/message/StructuredDataMessage.java | 91 +++-- 2 files changed, 260 insertions(+), 209 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2e42ea8b/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 d71b54a..ab99608 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 @@ -181,18 +181,6 @@ public class MapMessage<M extends MapMessage<M, V>, V> implements MultiformatMes } /** - * Adds 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} - */ - @SuppressWarnings("unchecked") - public M with(final String key, final String value) { - put(key, value); - return (M) this; - } - - /** * Adds an item to the data Map. * @param key The name of the data item. * @param value The value of the data item. @@ -206,163 +194,6 @@ public class MapMessage<M extends MapMessage<M, V>, V> implements MultiformatMes } /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final int value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final long value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final boolean value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final char value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final byte value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final short value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final Object value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final float value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - /** - * Adds an item to the data Map. - * @param key The name of the data item. - * @param value The value of the data item. - * @return this object - */ - @SuppressWarnings("unchecked") - public M with(final String key, final double value) { - validate(key, value); - data.putValue(key, value); - return (M) this; - } - - protected void validate(final String key, final boolean value) { - // do nothing - } - - protected void validate(final String key, final char value) { - // do nothing - } - - protected void validate(final String key, final byte value) { - // do nothing - } - - protected void validate(final String key, final short value) { - // do nothing - } - - protected void validate(final String key, final Object value) { - // do nothing - } - - protected void validate(final String key, final float value) { - // do nothing - } - - protected void validate(final String key, final double value) { - // do nothing - } - - protected void validate(final String key, final String value) { - // do nothing - } - - protected void validate(final String key, final int value) { - // do nothing - } - - protected void validate(final String key, final long value) { - // do nothing - } - - /** * Adds all the elements from the specified Map. * @param map The Map to add. */ @@ -626,4 +457,213 @@ public class MapMessage<M extends MapMessage<M, V>, V> implements MultiformatMes public Throwable getThrowable() { return null; } + /** + * @since 2.9 + */ + protected void validate(final String key, final boolean value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final byte value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final char value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final double value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final float value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final int value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final long value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final Object value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final short value) { + // do nothing + } + + /** + * @since 2.9 + */ + protected void validate(final String key, final String value) { + // do nothing + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final boolean value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final byte value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final char value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final double value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final float value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final int value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final long value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final Object value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds an item to the data Map. + * @param key The name of the data item. + * @param value The value of the data item. + * @return this object + * @since 2.9 + */ + @SuppressWarnings("unchecked") + public M with(final String key, final short value) { + validate(key, value); + data.putValue(key, value); + return (M) this; + } + + /** + * Adds 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} + */ + @SuppressWarnings("unchecked") + public M with(final String key, final String value) { + put(key, value); + return (M) this; + } + } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2e42ea8b/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 38cd92c..d610cc4 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 @@ -134,18 +134,6 @@ public class StructuredDataMessage extends MapMessage<StructuredDataMessage, Str } /** - * 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; - } - - /** * Returns the supported formats. * @return An array of the supported format names. */ @@ -216,25 +204,6 @@ public class StructuredDataMessage extends MapMessage<StructuredDataMessage, Str this.message = msg; } - - @Override - protected void validate(final String key, final String value) { - validateKey(key); - } - - private void validateKey(final String key) { - if (key.length() > MAX_LENGTH) { - throw new IllegalArgumentException("Structured data keys are limited to 32 characters. key: " + key); - } - for (int i = 0; i < key.length(); i++) { - final char c = key.charAt(i); - if (c < '!' || c > '~' || c == '=' || c == ']' || c == '"') { - throw new IllegalArgumentException("Structured data keys must contain printable US ASCII characters" + - "and may not contain a space, =, ], or \""); - } - } - } - /** * Formats the structured data as described in RFC 5424. * @@ -415,45 +384,87 @@ public class StructuredDataMessage extends MapMessage<StructuredDataMessage, Str protected void validate(String key, boolean value) { validateKey(key); } - + + /** + * @since 2.9 + */ + @Override + protected void validate(String key, byte value) { + validateKey(key); + } + + /** + * @since 2.9 + */ @Override protected void validate(String key, char value) { validateKey(key); } + /** + * @since 2.9 + */ @Override - protected void validate(String key, byte value) { + protected void validate(String key, double value) { validateKey(key); } - + + /** + * @since 2.9 + */ @Override - protected void validate(String key, short value) { + protected void validate(String key, float value) { validateKey(key); } + /** + * @since 2.9 + */ @Override - protected void validate(String key, Object value) { + protected void validate(String key, int value) { validateKey(key); } + /** + * @since 2.9 + */ @Override - protected void validate(String key, float value) { + protected void validate(String key, long value) { validateKey(key); } + /** + * @since 2.9 + */ @Override - protected void validate(String key, double value) { + protected void validate(String key, Object value) { validateKey(key); } + /** + * @since 2.9 + */ @Override - protected void validate(String key, int value) { + protected void validate(String key, short value) { validateKey(key); } @Override - protected void validate(String key, long value) { + protected void validate(final String key, final String value) { validateKey(key); } + private void validateKey(final String key) { + if (key.length() > MAX_LENGTH) { + throw new IllegalArgumentException("Structured data keys are limited to 32 characters. key: " + key); + } + for (int i = 0; i < key.length(); i++) { + final char c = key.charAt(i); + if (c < '!' || c > '~' || c == '=' || c == ']' || c == '"') { + throw new IllegalArgumentException("Structured data keys must contain printable US ASCII characters" + + "and may not contain a space, =, ], or \""); + } + } + } + }
