Skip to content

Commit

Permalink
Remove endpoint names.
Browse files Browse the repository at this point in the history
This isn't the right granularity of data about an endpoint and we never exposed this anywhere in the actual library.
  • Loading branch information
JakeWharton committed Oct 10, 2014
1 parent fa3965f commit 468e0ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 39 deletions.
5 changes: 0 additions & 5 deletions retrofit/src/main/java/retrofit/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
* @author Matt Hickman ([email protected])
*/
public interface Endpoint {

/** The base API URL. */
String getUrl();

/** A name for differentiating between multiple API URLs. */
String getName();

}
33 changes: 6 additions & 27 deletions retrofit/src/main/java/retrofit/Endpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,15 @@
* @author Matt Hickman ([email protected])
*/
public final class Endpoints {
private static final String DEFAULT_NAME = "default";

private Endpoints() {
}

/** Create a server with the provided URL. */
public static Endpoint newFixedEndpoint(String url) {
return new FixedEndpoint(url, DEFAULT_NAME);
}

/** Create an endpoint with the provided URL and name. */
public static Endpoint newFixedEndpoint(String url, String name) {
return new FixedEndpoint(url, name);
}

private static class FixedEndpoint implements Endpoint {
private final String apiUrl;
private final String name;

FixedEndpoint(String apiUrl, String name) {
this.apiUrl = apiUrl;
this.name = name;
}

@Override public String getUrl() {
return apiUrl;
}

@Override public String getName() {
return name;
}
public static Endpoint newFixedEndpoint(final String url) {
return new Endpoint() {
@Override public String getUrl() {
return url;
}
};
}
}
8 changes: 1 addition & 7 deletions retrofit/src/test/java/retrofit/EndpointsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
import static org.assertj.core.api.Assertions.assertThat;

public class EndpointsTest {
@Test public void endpointOnly() {
@Test public void endpoint() {
Endpoint endpoint = Endpoints.newFixedEndpoint("http://example.com");
assertThat(endpoint.getUrl()).isEqualTo("http://example.com");
}

@Test public void endpointAndName() {
Endpoint endpoint = Endpoints.newFixedEndpoint("http://example.com", "production");
assertThat(endpoint.getUrl()).isEqualTo("http://example.com");
assertThat(endpoint.getName()).isEqualTo("production");
}
}

0 comments on commit 468e0ef

Please sign in to comment.