UrlBuilder

public class UrlBuilder extends Object

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:

  • .CONFIG_COLUMNS - Specifies the column names whose values will be substituted into the format to generate the URL.
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

Constant Value: "url.columns"

public static final String CONFIG_COLUMNS_TO_ESCAPE

Constant Value: "url.columnsToEscape"

public static final String CONFIG_FORMAT

Constant Value: "url.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:

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