Incorporated changes for renaming Id to ValueBasedId and RestClient to ResourceDepotClient
This commit is contained in:
parent
f2e091127f
commit
a12286698b
|
@ -14,13 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/package com.google.gson.example.rest.client;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.example.model.Cart;
|
||||
import com.google.gson.example.model.LineItem;
|
||||
import com.google.gson.example.model.Order;
|
||||
import com.google.gson.rest.client.RestClient;
|
||||
import com.google.gson.rest.client.ResourceDepotClient;
|
||||
import com.google.gson.rest.client.RestClientStub;
|
||||
import com.google.gson.rest.client.RestServerConfig;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.ValueBasedId;
|
||||
import com.google.gson.webservice.definition.CallPath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,11 +35,12 @@ import java.util.logging.Level;
|
|||
*/
|
||||
public class OrderClient {
|
||||
public static final CallPath CALL_PATH = new CallPath("/rest/order");
|
||||
private final RestClient<Id<Order>, Order> restClient;
|
||||
private final ResourceDepotClient<ValueBasedId<Order>, Order> restClient;
|
||||
public OrderClient() {
|
||||
RestServerConfig serverConfig = new RestServerConfig("http://localhost");
|
||||
RestClientStub stub = new RestClientStub(serverConfig, Level.INFO);
|
||||
restClient = new RestClient<Id<Order>, Order>(stub, CALL_PATH, Order.class);
|
||||
restClient = new ResourceDepotClient<ValueBasedId<Order>, Order>(
|
||||
stub, CALL_PATH, Order.class, new Gson());
|
||||
}
|
||||
|
||||
public Order placeOrder(Cart cart) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package com.google.gson.example.model;
|
||||
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.ValueBasedId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,11 +25,11 @@ import java.util.List;
|
|||
*
|
||||
* @author inder
|
||||
*/
|
||||
public class Cart implements RestResource<Id<Cart>, Cart> {
|
||||
public class Cart implements RestResource<ValueBasedId<Cart>, Cart> {
|
||||
private final List<LineItem> lineItems;
|
||||
private final String buyerName;
|
||||
private final String creditCard;
|
||||
private Id<Cart> id;
|
||||
private ValueBasedId<Cart> id;
|
||||
|
||||
public Cart(List<LineItem> lineItems, String buyerName, String creditCard) {
|
||||
this.lineItems = lineItems;
|
||||
|
@ -50,17 +50,17 @@ public class Cart implements RestResource<Id<Cart>, Cart> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Id<Cart> getId() {
|
||||
public ValueBasedId<Cart> getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Id<Cart> id) {
|
||||
public void setId(ValueBasedId<Cart> id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasId() {
|
||||
return Id.isValid(id);
|
||||
return ValueBasedId.isValid(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,18 @@
|
|||
*/
|
||||
package com.google.gson.example.model;
|
||||
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.ValueBasedId;
|
||||
|
||||
/**
|
||||
* An order
|
||||
*
|
||||
* @author inder
|
||||
*/
|
||||
public class Order implements RestResource<Id<Order>, Order> {
|
||||
public class Order implements RestResource<ValueBasedId<Order>, Order> {
|
||||
public final Cart postedCart;
|
||||
public final String orderNumber;
|
||||
private Id<Order> id;
|
||||
private ValueBasedId<Order> id;
|
||||
|
||||
public Order(Cart postedCart, String orderNumber) {
|
||||
this.postedCart = postedCart;
|
||||
|
@ -42,17 +42,17 @@ public class Order implements RestResource<Id<Order>, Order> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Id<Order> getId() {
|
||||
public ValueBasedId<Order> getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Id<Order> id) {
|
||||
public void setId(ValueBasedId<Order> id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasId() {
|
||||
return Id.isValid(id);
|
||||
return ValueBasedId.isValid(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user