Constructs an URL from a MessageFormat
-style format string
and a set of columns to include in the URL.
Instances are immutable and thread-safe.
Nested Class Summary
class | UrlBuilder.Builder | Builder for constructing instances of UrlBuilder . |
Constant Summary
String | CONFIG_COLUMNS | |
String | CONFIG_COLUMNS_TO_ESCAPE | |
String | CONFIG_FORMAT |
Public Method Summary
String |
buildUrl(Map<String, ?> allColumnValues)
Builds the escaped URL.
|
static UrlBuilder |
fromConfiguration()
Constructs an
UrlBuilder from the Configuration
Required configuration parameters:
|
Set<String> |
getMissingColumns(Set<String> allColumns)
Gets the difference of the configured URL columns and the given set of all columns.
|
Inherited Method Summary
Constants
public static final String CONFIG_COLUMNS
public static final String CONFIG_COLUMNS_TO_ESCAPE
public static final String CONFIG_FORMAT
Public Methods
public String buildUrl (Map<String, ?> allColumnValues)
Builds the escaped URL. The given map of values may contain
unneeded columns, but it must contain all of the configured
.CONFIG_COLUMNS
columns.
Parameters
allColumnValues | a map from column names to column values |
---|
Returns
- the escaped URL, or null if one or more configured column names are missing
or have null values in
allColumnValues
public static UrlBuilder fromConfiguration ()
Constructs an UrlBuilder
from the Configuration
Required configuration parameters:
.CONFIG_COLUMNS
- Specifies the column names whose values will be substituted into the format to generate the URL.
Optional configuration parameters:
.CONFIG_FORMAT
- Specifies the format of the URL. The default value is "{0}"..CONFIG_COLUMNS_TO_ESCAPE
- Specifies the column names whose values will be URL escaped. Must be a subset of.CONFIG_COLUMNS
.
Returns
- an
UrlBuilder
public Set<String> getMissingColumns (Set<String> allColumns)
Gets the difference of the configured URL columns and the given set of all columns. The difference will be empty if all of the URL columns are present in the given set.
Parameters
allColumns | all columns |
---|
Returns
- the difference of columns