This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix! Updated starter application to be 1.0.0-alpha.6 compatible
- Loading branch information
1 parent
8d0f16b
commit 7fd20b9
Showing
14 changed files
with
343 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
src/main/java/com/tigrisdata/starter/collections/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright 2022 Tigris Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tigrisdata.starter.collections; | ||
|
||
import com.tigrisdata.db.annotation.TigrisDBCollectionField; | ||
import com.tigrisdata.db.annotation.TigrisDBCollectionPrimaryKey; | ||
import com.tigrisdata.db.type.TigrisCollectionType; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class Order implements TigrisCollectionType { | ||
|
||
@TigrisDBCollectionField(description = "A unique identifier for the order") | ||
@TigrisDBCollectionPrimaryKey(1) | ||
private final int id; | ||
|
||
@TigrisDBCollectionField(description = "The identifier of the user that placed the order") | ||
private final int userId; | ||
|
||
@TigrisDBCollectionField(description = "The total cost of the order") | ||
private final double orderTotal; | ||
|
||
@TigrisDBCollectionField(description = "The list of products that are part of this order") | ||
private final List<ProductItem> productItems; | ||
|
||
public Order(int id, int userId, double orderTotal, List<ProductItem> productItems) { | ||
this.id = id; | ||
this.userId = userId; | ||
this.orderTotal = orderTotal; | ||
this.productItems = productItems; | ||
} | ||
|
||
public static class ProductItem { | ||
@TigrisDBCollectionField(description = "The product identifier") | ||
private final int productId; | ||
|
||
@TigrisDBCollectionField(description = "The quantity of this product in this order") | ||
private final int quantity; | ||
|
||
public ProductItem(int productId, int quantity) { | ||
this.productId = productId; | ||
this.quantity = quantity; | ||
} | ||
|
||
public int getProductId() { | ||
return productId; | ||
} | ||
|
||
public int getQuantity() { | ||
return quantity; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ProductItem that = (ProductItem) o; | ||
|
||
if (productId != that.productId) return false; | ||
return quantity == that.quantity; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = productId; | ||
result = 31 * result + quantity; | ||
return result; | ||
} | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public int getUserId() { | ||
return userId; | ||
} | ||
|
||
public double getOrderTotal() { | ||
return orderTotal; | ||
} | ||
|
||
public List<ProductItem> getProductItems() { | ||
return productItems; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Order order = (Order) o; | ||
|
||
if (id != order.id) return false; | ||
if (userId != order.userId) return false; | ||
if (Double.compare(order.orderTotal, orderTotal) != 0) return false; | ||
return Objects.equals(productItems, order.productItems); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result; | ||
long temp; | ||
result = id; | ||
result = 31 * result + userId; | ||
temp = Double.doubleToLongBits(orderTotal); | ||
result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
result = 31 * result + (productItems != null ? productItems.hashCode() : 0); | ||
return result; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/main/java/com/tigrisdata/starter/collections/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2022 Tigris Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tigrisdata.starter.collections; | ||
|
||
import com.tigrisdata.db.annotation.TigrisDBCollectionField; | ||
import com.tigrisdata.db.annotation.TigrisDBCollectionPrimaryKey; | ||
import com.tigrisdata.db.type.TigrisCollectionType; | ||
|
||
import java.util.Objects; | ||
|
||
public class Product implements TigrisCollectionType { | ||
|
||
@TigrisDBCollectionField(description = "A unique identifier for the product") | ||
@TigrisDBCollectionPrimaryKey(1) | ||
private final int id; | ||
|
||
@TigrisDBCollectionField(description = "Name of the product") | ||
private final String name; | ||
|
||
@TigrisDBCollectionField(description = "Number of products available in the store") | ||
private final int quantity; | ||
|
||
@TigrisDBCollectionField(description = "Price of the product") | ||
private final double price; | ||
|
||
public Product(int id, String name, int quantity, double price) { | ||
this.id = id; | ||
this.name = name; | ||
this.quantity = quantity; | ||
this.price = price; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getQuantity() { | ||
return quantity; | ||
} | ||
|
||
public double getPrice() { | ||
return price; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Product product = (Product) o; | ||
|
||
if (id != product.id) return false; | ||
if (quantity != product.quantity) return false; | ||
if (Double.compare(product.price, price) != 0) return false; | ||
return Objects.equals(name, product.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result; | ||
long temp; | ||
result = id; | ||
result = 31 * result + (name != null ? name.hashCode() : 0); | ||
result = 31 * result + quantity; | ||
temp = Double.doubleToLongBits(price); | ||
result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.