forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUriPrefixer.java
More file actions
42 lines (32 loc) · 1011 Bytes
/
UriPrefixer.java
File metadata and controls
42 lines (32 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import static com.gooddata.Validate.notEmpty;
import static com.gooddata.Validate.notNull;
public class UriPrefixer {
private final URI defaultUri;
public UriPrefixer(URI uriPrefix) {
this.defaultUri = notNull(uriPrefix, "uriPrefix");
}
public UriPrefixer(String uriPrefix) {
this(URI.create(uriPrefix));
}
public URI getDefaultUri() {
return defaultUri;
}
public URI mergeUris(URI uri) {
notNull(uri, "uri");
return UriComponentsBuilder.fromUri(defaultUri)
.path(uri.getRawPath())
.query(uri.getRawQuery())
.fragment(uri.getRawFragment())
.build().toUri();
}
public URI mergeUris(String uri) {
notEmpty(uri, "uri");
return mergeUris(URI.create(uri));
}
}