Skip to content

Commit

Permalink
Rename response classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Feb 16, 2016
1 parent 539ba3a commit 44354fe
Show file tree
Hide file tree
Showing 63 changed files with 304 additions and 305 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/stellar/sdk/Memo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.stellar.sdk;

import org.apache.commons.codec.DecoderException;
import org.stellar.sdk.responses.Transaction;

/**
* <p>The memo contains optional extra information. It is the responsibility of the client to interpret this value. Memos can be one of the following types:</p>
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.responses.Account;
import org.stellar.sdk.responses.AccountResponse;
import org.stellar.sdk.responses.GsonSingleton;
import org.stellar.sdk.responses.Page;

Expand All @@ -27,14 +27,14 @@ public AccountsRequestBuilder(URI serverURI) {
}

/**
* Requests specific <code>uri</code> and returns {@link Account}.
* Requests specific <code>uri</code> and returns {@link AccountResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
public Account account(URI uri) throws IOException {
TypeToken type = new TypeToken<Account>() {};
ResponseHandler<Account> responseHandler = new ResponseHandler<Account>(type);
return (Account) Request.Get(uri).execute().handleResponse(responseHandler);
public AccountResponse account(URI uri) throws IOException {
TypeToken type = new TypeToken<AccountResponse>() {};
ResponseHandler<AccountResponse> responseHandler = new ResponseHandler<AccountResponse>(type);
return (AccountResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -43,21 +43,21 @@ public Account account(URI uri) throws IOException {
* @param account Account to fetch
* @throws IOException
*/
public Account account(KeyPair account) throws IOException {
public AccountResponse account(KeyPair account) throws IOException {
this.setSegments("accounts", account.getAddress());
return this.account(this.buildUri());
}

/**
* Requests specific <code>uri</code> and returns {@link Page} of {@link Account}.
* Requests specific <code>uri</code> and returns {@link Page} of {@link AccountResponse}.
* This method is helpful for getting the next set of results.
* @return {@link Page} of {@link Account}
* @return {@link Page} of {@link AccountResponse}
* @throws IOException
*/
public static Page<Account> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<Account>>() {};
ResponseHandler<Page<Account>> responseHandler = new ResponseHandler<Page<Account>>(type);
return (Page<Account>) Request.Get(uri).execute().handleResponse(responseHandler);
public static Page<AccountResponse> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<AccountResponse>>() {};
ResponseHandler<Page<AccountResponse>> responseHandler = new ResponseHandler<Page<AccountResponse>>(type);
return (Page<AccountResponse>) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -67,10 +67,10 @@ public static Page<Account> execute(URI uri) throws IOException {
* responses as ledgers close.
* @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
* @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
* @param listener {@link EventListener} implementation with {@link Account} type
* @param listener {@link EventListener} implementation with {@link AccountResponse} type
* @return EventSource object, so you can <code>close()</code> connection when not needed anymore
*/
public EventSource stream(final EventListener<Account> listener) {
public EventSource stream(final EventListener<AccountResponse> listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
Expand All @@ -80,19 +80,19 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
Account account = GsonSingleton.getInstance().fromJson(data, Account.class);
AccountResponse account = GsonSingleton.getInstance().fromJson(data, AccountResponse.class);
listener.onEvent(account);
}
};
return eventSource;
}

/**
* Build and execute request. <strong>Warning!</strong> {@link Account}s in {@link Page} will contain only <code>keypair</code> field.
* @return {@link Page} of {@link Account}
* Build and execute request. <strong>Warning!</strong> {@link AccountResponse}s in {@link Page} will contain only <code>keypair</code> field.
* @return {@link Page} of {@link AccountResponse}
* @throws IOException
*/
public Page<Account> execute() throws IOException {
public Page<AccountResponse> execute() throws IOException {
return this.execute(this.buildUri());
}

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.responses.GsonSingleton;
import org.stellar.sdk.responses.Page;
import org.stellar.sdk.responses.effects.Effect;
import org.stellar.sdk.responses.effects.EffectResponse;

import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -71,15 +71,15 @@ public EffectsRequestBuilder forOperation(long operationId) {
}

/**
* Requests specific <code>uri</code> and returns {@link Page} of {@link Effect}.
* Requests specific <code>uri</code> and returns {@link Page} of {@link EffectResponse}.
* This method is helpful for getting the next set of results.
* @return {@link Page} of {@link Effect}
* @return {@link Page} of {@link EffectResponse}
* @throws IOException
*/
public static Page<Effect> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<Effect>>() {};
ResponseHandler<Page<Effect>> responseHandler = new ResponseHandler<Page<Effect>>(type);
return (Page<Effect>) Request.Get(uri).execute().handleResponse(responseHandler);
public static Page<EffectResponse> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<EffectResponse>>() {};
ResponseHandler<Page<EffectResponse>> responseHandler = new ResponseHandler<Page<EffectResponse>>(type);
return (Page<EffectResponse>) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -89,10 +89,10 @@ public static Page<Effect> execute(URI uri) throws IOException {
* responses as ledgers close.
* @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
* @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
* @param listener {@link EventListener} implementation with {@link Effect} type
* @param listener {@link EventListener} implementation with {@link EffectResponse} type
* @return EventSource object, so you can <code>close()</code> connection when not needed anymore
*/
public EventSource stream(final EventListener<Effect> listener) {
public EventSource stream(final EventListener<EffectResponse> listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
Expand All @@ -102,7 +102,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
Effect effect = GsonSingleton.getInstance().fromJson(data, Effect.class);
EffectResponse effect = GsonSingleton.getInstance().fromJson(data, EffectResponse.class);
listener.onEvent(effect);
}
};
Expand All @@ -111,10 +111,10 @@ public void onEvent(InboundEvent inboundEvent) {

/**
* Build and execute request.
* @return {@link Page} of {@link Effect}
* @return {@link Page} of {@link EffectResponse}
* @throws IOException
*/
public Page<Effect> execute() throws IOException {
public Page<EffectResponse> execute() throws IOException {
return this.execute(this.buildUri());
}

Expand Down
36 changes: 18 additions & 18 deletions src/main/java/org/stellar/sdk/requests/LedgersRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
import org.stellar.sdk.responses.GsonSingleton;
import org.stellar.sdk.responses.Ledger;
import org.stellar.sdk.responses.LedgerResponse;
import org.stellar.sdk.responses.Page;

import java.io.IOException;
Expand All @@ -26,14 +26,14 @@ public LedgersRequestBuilder(URI serverURI) {
}

/**
* Requests specific <code>uri</code> and returns {@link Ledger}.
* Requests specific <code>uri</code> and returns {@link LedgerResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
public Ledger ledger(URI uri) throws IOException {
TypeToken type = new TypeToken<Ledger>() {};
ResponseHandler<Ledger> responseHandler = new ResponseHandler<Ledger>(type);
return (Ledger) Request.Get(uri).execute().handleResponse(responseHandler);
public LedgerResponse ledger(URI uri) throws IOException {
TypeToken type = new TypeToken<LedgerResponse>() {};
ResponseHandler<LedgerResponse> responseHandler = new ResponseHandler<LedgerResponse>(type);
return (LedgerResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -42,21 +42,21 @@ public Ledger ledger(URI uri) throws IOException {
* @param ledgerSeq Ledger to fetch
* @throws IOException
*/
public Ledger ledger(long ledgerSeq) throws IOException {
public LedgerResponse ledger(long ledgerSeq) throws IOException {
this.setSegments("ledgers", String.valueOf(ledgerSeq));
return this.ledger(this.buildUri());
}

/**
* Requests specific <code>uri</code> and returns {@link Page} of {@link Ledger}.
* Requests specific <code>uri</code> and returns {@link Page} of {@link LedgerResponse}.
* This method is helpful for getting the next set of results.
* @return {@link Page} of {@link Ledger}
* @return {@link Page} of {@link LedgerResponse}
* @throws IOException
*/
public static Page<Ledger> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<Ledger>>() {};
ResponseHandler<Page<Ledger>> responseHandler = new ResponseHandler<Page<Ledger>>(type);
return (Page<Ledger>) Request.Get(uri).execute().handleResponse(responseHandler);
public static Page<LedgerResponse> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<LedgerResponse>>() {};
ResponseHandler<Page<LedgerResponse>> responseHandler = new ResponseHandler<Page<LedgerResponse>>(type);
return (Page<LedgerResponse>) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -66,10 +66,10 @@ public static Page<Ledger> execute(URI uri) throws IOException {
* responses as ledgers close.
* @see <a href="http://www.w3.org/TR/eventsource/" target="_blank">Server-Sent Events</a>
* @see <a href="https://www.stellar.org/developers/horizon/learn/responses.html" target="_blank">Response Format documentation</a>
* @param listener {@link EventListener} implementation with {@link Ledger} type
* @param listener {@link EventListener} implementation with {@link LedgerResponse} type
* @return EventSource object, so you can <code>close()</code> connection when not needed anymore
*/
public EventSource stream(final EventListener<Ledger> listener) {
public EventSource stream(final EventListener<LedgerResponse> listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
Expand All @@ -79,7 +79,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
Ledger ledger = GsonSingleton.getInstance().fromJson(data, Ledger.class);
LedgerResponse ledger = GsonSingleton.getInstance().fromJson(data, LedgerResponse.class);
listener.onEvent(ledger);
}
};
Expand All @@ -88,10 +88,10 @@ public void onEvent(InboundEvent inboundEvent) {

/**
* Build and execute request.
* @return {@link Page} of {@link Ledger}
* @return {@link Page} of {@link LedgerResponse}
* @throws IOException
*/
public Page<Ledger> execute() throws IOException {
public Page<LedgerResponse> execute() throws IOException {
return this.execute(this.buildUri());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.apache.http.client.fluent.Request;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.responses.Page;
import org.stellar.sdk.responses.operations.Operation;
import org.stellar.sdk.responses.operations.OperationResponse;

import java.io.IOException;
import java.net.URI;
Expand All @@ -21,14 +21,14 @@ public OperationsRequestBuilder(URI serverURI) {
}

/**
* Requests specific <code>uri</code> and returns {@link Operation}.
* Requests specific <code>uri</code> and returns {@link OperationResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
public Operation operation(URI uri) throws IOException {
TypeToken type = new TypeToken<Operation>() {};
ResponseHandler<Operation> responseHandler = new ResponseHandler<Operation>(type);
return (Operation) Request.Get(uri).execute().handleResponse(responseHandler);
public OperationResponse operation(URI uri) throws IOException {
TypeToken type = new TypeToken<OperationResponse>() {};
ResponseHandler<OperationResponse> responseHandler = new ResponseHandler<OperationResponse>(type);
return (OperationResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
Expand All @@ -37,7 +37,7 @@ public Operation operation(URI uri) throws IOException {
* @param operationId Operation to fetch
* @throws IOException
*/
public Operation operation(long operationId) throws IOException {
public OperationResponse operation(long operationId) throws IOException {
this.setSegments("operation", String.valueOf(operationId));
return this.operation(this.buildUri());
}
Expand Down Expand Up @@ -75,23 +75,23 @@ public OperationsRequestBuilder forTransaction(String transactionId) {
}

/**
* Requests specific <code>uri</code> and returns {@link Page} of {@link Operation}.
* Requests specific <code>uri</code> and returns {@link Page} of {@link OperationResponse}.
* This method is helpful for getting the next set of results.
* @return {@link Page} of {@link Operation}
* @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
public static Page<Operation> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<Operation>>() {};
ResponseHandler<Page<Operation>> responseHandler = new ResponseHandler<Page<Operation>>(type);
return (Page<Operation>) Request.Get(uri).execute().handleResponse(responseHandler);
public static Page<OperationResponse> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<OperationResponse>>() {};
ResponseHandler<Page<OperationResponse>> responseHandler = new ResponseHandler<Page<OperationResponse>>(type);
return (Page<OperationResponse>) Request.Get(uri).execute().handleResponse(responseHandler);
}

/**
* Build and execute request.
* @return {@link Page} of {@link Operation}
* @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
public Page<Operation> execute() throws IOException {
public Page<OperationResponse> execute() throws IOException {
return this.execute(this.buildUri());
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.stellar.sdk.AssetTypeCreditAlphaNum;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.responses.Page;
import org.stellar.sdk.responses.Path;
import org.stellar.sdk.responses.PathResponse;

import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -45,13 +45,13 @@ public PathsRequestBuilder destinationAsset(Asset asset) {
return this;
}

public static Page<Path> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<Path>>() {};
ResponseHandler<Page<Path>> responseHandler = new ResponseHandler<Page<Path>>(type);
return (Page<Path>) Request.Get(uri).execute().handleResponse(responseHandler);
public static Page<PathResponse> execute(URI uri) throws IOException {
TypeToken type = new TypeToken<Page<PathResponse>>() {};
ResponseHandler<Page<PathResponse>> responseHandler = new ResponseHandler<Page<PathResponse>>(type);
return (Page<PathResponse>) Request.Get(uri).execute().handleResponse(responseHandler);
}

public Page<Path> execute() throws IOException {
public Page<PathResponse> execute() throws IOException {
return this.execute(this.buildUri());
}
}
Loading

0 comments on commit 44354fe

Please sign in to comment.