public class Location extends Object implements Serializable
For related utility methods, see LocationUtil.
| Constructor and Description |
|---|
Location(List<String> segments)
Creates a new location based on a list of path segments.
|
Location(List<String> segments,
QueryParameters queryParameters)
Creates a new location based on a list of path segments and query
parameters.
|
Location(String location)
Creates a new
Location object for given location string. |
Location(String location,
QueryParameters queryParameters)
Creates a new
Location object for given location string and query
parameters. |
| Modifier and Type | Method and Description |
|---|---|
String |
getFirstSegment()
Gets the first segment of this path.
|
String |
getPath()
Gets the path of this location as a string.
|
String |
getPathWithQueryParameters()
Gets the path string with
QueryParameters and including the
possible fragment if one existed. |
QueryParameters |
getQueryParameters()
Gets the request parameters used for current location.
|
List<String> |
getSegments()
Gets all the path segments of this location.
|
Optional<Location> |
getSubLocation()
Creates a new location without the first path segment.
|
Location |
toggleTrailingSlash()
Removes or adds slash to the end of the location path.
|
public Location(String location) throws InvalidLocationException
Location object for given location string.
This string can contain relative path and query parameters, if needed. A
possible fragment #fragment is also retained.
A possible "/" prefix of the location is ignored and a null
location is interpreted as ""
location - the relative location, not nullInvalidLocationException - If the given string cannot be used for the Locationpublic Location(String location, QueryParameters queryParameters) throws InvalidLocationException
Location object for given location string and query
parameters.
The location string can not contain query parameters. To pass query
parameters, either specify them in QueryParameters in this
constructor, or use Location(String)
A possible "/" prefix of the location is ignored and a null
location is interpreted as ""
location - the relative location or null which is
interpreted as ""queryParameters - query parameters information, not nullIllegalArgumentException - if location string contains query parameters insideInvalidLocationException - If the given string cannot be used for the Locationpublic Location(List<String> segments)
segments - a non-empty list of path segments, not nullpublic Location(List<String> segments, QueryParameters queryParameters)
segments - a non-empty list of path segments, not null and not
emptyqueryParameters - query parameters information, not nullpublic List<String> getSegments()
public QueryParameters getQueryParameters()
public String getFirstSegment()
nullpublic Optional<Location> getSubLocation()
public String getPath()
nullpublic String getPathWithQueryParameters()
QueryParameters and including the
possible fragment if one existed.Copyright © 2025. All rights reserved.