/** * Create an empty LinkBuilder, with no URL pattern. Using this constructor * mandates that you MUST use the build(String) form of build instead of the * parameterless, build() or other forms, as the latter will throw * IllegalStateException in this state, due to not having a URL in the * generated link. */ public DefaultLinkBuilder() { super(); urlBuilder = new DefaultUrlBuilder(); }
@Override public UrlBuilder newUrlBuilder() { return new DefaultUrlBuilder(); }
/** * Create a new LinkBuilder, passing in the URL pattern in which to * substitute tokens. This URL pattern may represent the entire URL or just * the path portion (relative path). * <p/> * The URL pattern is templated, in that it contains tokens to be later * substituted for actual values. The tokens are delimited with beginning * and trailing curly-braces (e.g. '{token}'). * <p/> * If used in conjunction with baseUrl(), this URL pattern must be just the * path portion of the URL and should be prefixed with a leading slash * ('/'). * <p/> * For example: '/users/{userId}' or * 'http://www.example.com/api/users/{userId}' * * @param urlPattern a URL path with optional tokens of the form '{tokenName}' */ public DefaultLinkBuilder(String urlPattern) { super(); urlBuilder = new DefaultUrlBuilder(urlPattern); }
@Override public DefaultUrlBuilder clone() { DefaultUrlBuilder b = new DefaultUrlBuilder(this.urlPattern); b.baseUrl = this.baseUrl; b.queries = (this.queries == null ? null : new ArrayList<String>(this.queries)); return b; }