public class HeaderSupplier extends Object implements Iterable<Header>
Header
objects.
This class is thread safe.Modifier and Type | Class and Description |
---|---|
static class |
HeaderSupplier.Null
Represents no header supplier
|
Constructor and Description |
---|
HeaderSupplier() |
Modifier and Type | Method and Description |
---|---|
HeaderSupplier |
add(Header h)
Add a header to this supplier.
|
HeaderSupplier |
add(HeaderSupplier h)
Add a supplier to this supplier.
|
HeaderSupplier |
add(String name,
Object value)
Appends the specified header to the end of this list.
|
HeaderSupplier |
add(String name,
Object value,
HttpPartSerializerSession serializer,
HttpPartSchema schema,
boolean skipIfEmpty)
Appends the specified header to the end of this list.
|
HeaderSupplier |
add(String name,
Supplier<?> value)
Appends the specifiedheader to the end of this list using a value supplier.
|
static HeaderSupplier |
create()
Convenience creator.
|
Iterator<Header> |
iterator() |
static HeaderSupplier |
of()
Creates an empty instance.
|
static HeaderSupplier |
of(Collection<Header> headers)
Creates an instance initialized with the specified headers.
|
static HeaderSupplier |
of(Object... values)
Convenience creator.
|
static HeaderSupplier |
ofPairs(Object... parameters)
Creates an instance initialized with the specified name/value pairs.
|
HeaderSupplier |
resolving()
Allows header values to contain SVL variables.
|
HeaderSupplier |
resolving(VarResolver varResolver)
Allows header values to contain SVL variables.
|
Header[] |
toArray()
Returns these headers as an array.
|
<T extends Header> |
toArray(T[] array)
Returns these headers as an array.
|
String |
toString()
Returns this list as a JSON list of strings.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public HeaderSupplier()
public static HeaderSupplier create()
HeaderSupplier
object.public static HeaderSupplier of()
public static HeaderSupplier of(Collection<Header> headers)
headers
- The headers to add to this list.public static HeaderSupplier ofPairs(Object... parameters)
parameters
- Initial list of parameters.
RuntimeException
- If odd number of parameters were specified.public static HeaderSupplier of(Object... values)
values
- The values to populate this supplier with.
HeaderSupplier
object.public HeaderSupplier resolving()
Resolves variables in header values when using the following methods:
ofPairs(Object...)
add(String,Object)
add(String,Supplier<?>)
add(String,Object,HttpPartSerializerSession,HttpPartSchema,boolean)
Uses VarResolver.DEFAULT
to resolve variables.
public HeaderSupplier resolving(VarResolver varResolver)
Resolves variables in header values when using the following methods:
varResolver
- The variable resolver to use for resolving variables.public HeaderSupplier add(Header h)
h
- The header to add. public HeaderSupplier add(HeaderSupplier h)
h
- The supplier to add. public HeaderSupplier add(String name, Object value)
The header is added as a BasicHeader
.
name
- The header name.value
- The header value.public HeaderSupplier add(String name, Supplier<?> value)
The header is added as a BasicHeader
.
Value is re-evaluated on each call to BasicHeader.getValue()
.
name
- The header name.value
- The header value supplier.public HeaderSupplier add(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty)
name
- The header name.value
- The header value.serializer
- The serializer to use for serializing the value to a string value.schema
- The schema object that defines the format of the output.
HttpPartSchema.DEFAULT
.
OpenApiSerializer
).skipIfEmpty
- If value is a blank string, the value should return as public Header[] toArray()
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.