Headers set/add/contains timeMillis methods
Motivation: The new Headers interface contains methods to getTimeMillis but no add/set/contains variants. These should be added for consistency. Modifications: - Add three new methods: addTimeMillis, setTimeMillis, containsTimeMillis to the Headers interface. - Add a new method to the Headers.ValueConverter interface: T convertTimeMillis(long) - Bring these new interfaces up the class hierarchy Result: All Headers classes have setters/getters for timeMillis.
This commit is contained in:
parent
23db94f5a1
commit
8206cc6e14
@ -140,6 +140,12 @@ public class DefaultSpdyHeaders extends DefaultTextHeaders implements SpdyHeader
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpdyHeaders addTimeMillis(CharSequence name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpdyHeaders add(TextHeaders headers) {
|
public SpdyHeaders add(TextHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -230,6 +236,12 @@ public class DefaultSpdyHeaders extends DefaultTextHeaders implements SpdyHeader
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpdyHeaders setTimeMillis(CharSequence name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpdyHeaders set(TextHeaders headers) {
|
public SpdyHeaders set(TextHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -98,6 +98,9 @@ public interface SpdyHeaders extends TextHeaders {
|
|||||||
@Override
|
@Override
|
||||||
SpdyHeaders addDouble(CharSequence name, double value);
|
SpdyHeaders addDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
SpdyHeaders addTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
SpdyHeaders add(TextHeaders headers);
|
SpdyHeaders add(TextHeaders headers);
|
||||||
|
|
||||||
@ -134,6 +137,9 @@ public interface SpdyHeaders extends TextHeaders {
|
|||||||
@Override
|
@Override
|
||||||
SpdyHeaders setDouble(CharSequence name, double value);
|
SpdyHeaders setDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
SpdyHeaders setTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
SpdyHeaders setObject(CharSequence name, Object value);
|
SpdyHeaders setObject(CharSequence name, Object value);
|
||||||
|
|
||||||
|
@ -105,6 +105,12 @@ public class DefaultStompHeaders extends DefaultTextHeaders implements StompHead
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StompHeaders addTimeMillis(CharSequence name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StompHeaders add(TextHeaders headers) {
|
public StompHeaders add(TextHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -195,6 +201,12 @@ public class DefaultStompHeaders extends DefaultTextHeaders implements StompHead
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StompHeaders setTimeMillis(CharSequence name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StompHeaders set(TextHeaders headers) {
|
public StompHeaders set(TextHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -86,6 +86,9 @@ public interface StompHeaders extends TextHeaders {
|
|||||||
@Override
|
@Override
|
||||||
StompHeaders addDouble(CharSequence name, double value);
|
StompHeaders addDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
StompHeaders addTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
StompHeaders add(TextHeaders headers);
|
StompHeaders add(TextHeaders headers);
|
||||||
|
|
||||||
@ -131,6 +134,9 @@ public interface StompHeaders extends TextHeaders {
|
|||||||
@Override
|
@Override
|
||||||
StompHeaders setDouble(CharSequence name, double value);
|
StompHeaders setDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
StompHeaders setTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
StompHeaders set(TextHeaders headers);
|
StompHeaders set(TextHeaders headers);
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@ public interface BinaryHeaders extends Headers<AsciiString> {
|
|||||||
@Override
|
@Override
|
||||||
BinaryHeaders addDouble(AsciiString name, double value);
|
BinaryHeaders addDouble(AsciiString name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BinaryHeaders addTimeMillis(AsciiString name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link Headers#add(Headers)}
|
* See {@link Headers#add(Headers)}
|
||||||
*/
|
*/
|
||||||
@ -123,6 +126,9 @@ public interface BinaryHeaders extends Headers<AsciiString> {
|
|||||||
@Override
|
@Override
|
||||||
BinaryHeaders setDouble(AsciiString name, double value);
|
BinaryHeaders setDouble(AsciiString name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BinaryHeaders setTimeMillis(AsciiString name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link Headers#set(Headers)}
|
* See {@link Headers#set(Headers)}
|
||||||
*/
|
*/
|
||||||
|
@ -81,6 +81,11 @@ public class DefaultBinaryHeaders extends DefaultHeaders<AsciiString> implements
|
|||||||
return value.parseLong();
|
return value.parseLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AsciiString convertTimeMillis(long value) {
|
||||||
|
return new AsciiString(String.valueOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long convertToTimeMillis(AsciiString value) {
|
public long convertToTimeMillis(AsciiString value) {
|
||||||
try {
|
try {
|
||||||
@ -239,6 +244,12 @@ public class DefaultBinaryHeaders extends DefaultHeaders<AsciiString> implements
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryHeaders addTimeMillis(AsciiString name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryHeaders add(BinaryHeaders headers) {
|
public BinaryHeaders add(BinaryHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -329,6 +340,12 @@ public class DefaultBinaryHeaders extends DefaultHeaders<AsciiString> implements
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryHeaders setTimeMillis(AsciiString name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryHeaders set(BinaryHeaders headers) {
|
public BinaryHeaders set(BinaryHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -378,6 +378,11 @@ public class DefaultHeaders<T> implements Headers<T> {
|
|||||||
return contains(name, valueConverter.convertDouble(checkNotNull(value, "value")));
|
return contains(name, valueConverter.convertDouble(checkNotNull(value, "value")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsTimeMillis(T name, long value) {
|
||||||
|
return contains(name, valueConverter.convertTimeMillis(checkNotNull(value, "value")));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(T name, T value, Comparator<? super T> comparator) {
|
public boolean contains(T name, T value, Comparator<? super T> comparator) {
|
||||||
return contains(name, value, comparator, comparator);
|
return contains(name, value, comparator, comparator);
|
||||||
@ -550,6 +555,11 @@ public class DefaultHeaders<T> implements Headers<T> {
|
|||||||
return add(name, valueConverter.convertDouble(value));
|
return add(name, valueConverter.convertDouble(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Headers<T> addTimeMillis(T name, long value) {
|
||||||
|
return add(name, valueConverter.convertTimeMillis(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Headers<T> addChar(T name, char value) {
|
public Headers<T> addChar(T name, char value) {
|
||||||
return add(name, valueConverter.convertChar(value));
|
return add(name, valueConverter.convertChar(value));
|
||||||
@ -690,6 +700,11 @@ public class DefaultHeaders<T> implements Headers<T> {
|
|||||||
return set(name, valueConverter.convertDouble(value));
|
return set(name, valueConverter.convertDouble(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Headers<T> setTimeMillis(T name, long value) {
|
||||||
|
return set(name, valueConverter.convertTimeMillis(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Headers<T> setFloat(T name, float value) {
|
public Headers<T> setFloat(T name, float value) {
|
||||||
return set(name, valueConverter.convertFloat(value));
|
return set(name, valueConverter.convertFloat(value));
|
||||||
|
@ -119,6 +119,11 @@ public class DefaultTextHeaders extends DefaultConvertibleHeaders<CharSequence,
|
|||||||
return Long.parseLong(value.toString());
|
return Long.parseLong(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AsciiString convertTimeMillis(long value) {
|
||||||
|
return new AsciiString(String.valueOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long convertToTimeMillis(CharSequence value) {
|
public long convertToTimeMillis(CharSequence value) {
|
||||||
try {
|
try {
|
||||||
@ -268,6 +273,12 @@ public class DefaultTextHeaders extends DefaultConvertibleHeaders<CharSequence,
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextHeaders addTimeMillis(CharSequence name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextHeaders add(TextHeaders headers) {
|
public TextHeaders add(TextHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -358,6 +369,12 @@ public class DefaultTextHeaders extends DefaultConvertibleHeaders<CharSequence,
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextHeaders setTimeMillis(CharSequence name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextHeaders set(TextHeaders headers) {
|
public TextHeaders set(TextHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -104,6 +104,12 @@ public class EmptyBinaryHeaders extends EmptyHeaders<AsciiString> implements Bin
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryHeaders addTimeMillis(AsciiString name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryHeaders add(BinaryHeaders headers) {
|
public BinaryHeaders add(BinaryHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -194,6 +200,12 @@ public class EmptyBinaryHeaders extends EmptyHeaders<AsciiString> implements Bin
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryHeaders setTimeMillis(AsciiString name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryHeaders set(BinaryHeaders headers) {
|
public BinaryHeaders set(BinaryHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -292,6 +292,11 @@ public class EmptyHeaders<T> implements Headers<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsTimeMillis(T name, long value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(T name, T value, Comparator<? super T> comparator) {
|
public boolean contains(T name, T value, Comparator<? super T> comparator) {
|
||||||
return false;
|
return false;
|
||||||
@ -404,6 +409,11 @@ public class EmptyHeaders<T> implements Headers<T> {
|
|||||||
throw new UnsupportedOperationException("read only");
|
throw new UnsupportedOperationException("read only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Headers<T> addTimeMillis(T name, long value) {
|
||||||
|
throw new UnsupportedOperationException("read only");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Headers<T> add(Headers<T> headers) {
|
public Headers<T> add(Headers<T> headers) {
|
||||||
throw new UnsupportedOperationException("read only");
|
throw new UnsupportedOperationException("read only");
|
||||||
@ -479,6 +489,11 @@ public class EmptyHeaders<T> implements Headers<T> {
|
|||||||
throw new UnsupportedOperationException("read only");
|
throw new UnsupportedOperationException("read only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Headers<T> setTimeMillis(T name, long value) {
|
||||||
|
throw new UnsupportedOperationException("read only");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Headers<T> set(Headers<T> headers) {
|
public Headers<T> set(Headers<T> headers) {
|
||||||
throw new UnsupportedOperationException("read only");
|
throw new UnsupportedOperationException("read only");
|
||||||
|
@ -114,6 +114,12 @@ public class EmptyTextHeaders extends EmptyConvertibleHeaders<CharSequence, Stri
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextHeaders addTimeMillis(CharSequence name, long value) {
|
||||||
|
super.addTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextHeaders add(TextHeaders headers) {
|
public TextHeaders add(TextHeaders headers) {
|
||||||
super.add(headers);
|
super.add(headers);
|
||||||
@ -204,6 +210,12 @@ public class EmptyTextHeaders extends EmptyConvertibleHeaders<CharSequence, Stri
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextHeaders setTimeMillis(CharSequence name, long value) {
|
||||||
|
super.setTimeMillis(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextHeaders set(TextHeaders headers) {
|
public TextHeaders set(TextHeaders headers) {
|
||||||
super.set(headers);
|
super.set(headers);
|
||||||
|
@ -78,6 +78,8 @@ public interface Headers<T> extends Iterable<Map.Entry<T, T>> {
|
|||||||
|
|
||||||
long convertToLong(T value);
|
long convertToLong(T value);
|
||||||
|
|
||||||
|
T convertTimeMillis(long value);
|
||||||
|
|
||||||
long convertToTimeMillis(T value);
|
long convertToTimeMillis(T value);
|
||||||
|
|
||||||
T convertFloat(float value);
|
T convertFloat(float value);
|
||||||
@ -626,6 +628,15 @@ public interface Headers<T> extends Iterable<Map.Entry<T, T>> {
|
|||||||
*/
|
*/
|
||||||
boolean containsDouble(T name, double value);
|
boolean containsDouble(T name, double value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if a header with the name and value exists.
|
||||||
|
*
|
||||||
|
* @param name the header name
|
||||||
|
* @param value the header value
|
||||||
|
* @return {@code true} if it contains it {@code false} otherwise
|
||||||
|
*/
|
||||||
|
boolean containsTimeMillis(T name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if a header with the name and value exists.
|
* Returns {@code true} if a header with the name and value exists.
|
||||||
*
|
*
|
||||||
@ -857,6 +868,14 @@ public interface Headers<T> extends Iterable<Map.Entry<T, T>> {
|
|||||||
*/
|
*/
|
||||||
Headers<T> addDouble(T name, double value);
|
Headers<T> addDouble(T name, double value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the {@code name} to {@code value}.
|
||||||
|
* @param name The name to modify
|
||||||
|
* @param value The value
|
||||||
|
* @return {@code this}
|
||||||
|
*/
|
||||||
|
Headers<T> addTimeMillis(T name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all header entries of the specified {@code headers}.
|
* Adds all header entries of the specified {@code headers}.
|
||||||
*
|
*
|
||||||
@ -1034,6 +1053,14 @@ public interface Headers<T> extends Iterable<Map.Entry<T, T>> {
|
|||||||
*/
|
*/
|
||||||
Headers<T> setDouble(T name, double value);
|
Headers<T> setDouble(T name, double value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@code name} to {@code value}. This will remove all previous values associated with {@code name}.
|
||||||
|
* @param name The name to modify
|
||||||
|
* @param value The value
|
||||||
|
* @return {@code this}
|
||||||
|
*/
|
||||||
|
Headers<T> setTimeMillis(T name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the current header entries and copies all header entries of the specified {@code headers}.
|
* Cleans the current header entries and copies all header entries of the specified {@code headers}.
|
||||||
*
|
*
|
||||||
|
@ -95,6 +95,9 @@ public interface TextHeaders extends ConvertibleHeaders<CharSequence, String> {
|
|||||||
@Override
|
@Override
|
||||||
TextHeaders addDouble(CharSequence name, double value);
|
TextHeaders addDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
TextHeaders addTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link Headers#add(Headers)}
|
* See {@link Headers#add(Headers)}
|
||||||
*/
|
*/
|
||||||
@ -142,6 +145,9 @@ public interface TextHeaders extends ConvertibleHeaders<CharSequence, String> {
|
|||||||
@Override
|
@Override
|
||||||
TextHeaders setDouble(CharSequence name, double value);
|
TextHeaders setDouble(CharSequence name, double value);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
TextHeaders setTimeMillis(CharSequence name, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link Headers#set(Headers)}
|
* See {@link Headers#set(Headers)}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user