Commit 2e42ea8b authored by Gary Gregory's avatar Gary Gregory
Browse files

Order the new methods in AB order and add @since 2.9 tags.

parent ec27fe7b
Showing with 260 additions and 209 deletions
+260 -209
......@@ -180,18 +180,6 @@ public class MapMessage<M extends MapMessage<M, V>, V> implements MultiformatMes
return data.containsKey(key);
}
/**
* 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.
......@@ -205,163 +193,6 @@ public class MapMessage<M extends MapMessage<M, V>, V> implements MultiformatMes
data.putValue(key, value);
}
/**
* 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;
}
}
......@@ -133,18 +133,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 \"");
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment