Refactor example POS application model classes to be conducive to Jackson's ObjectMapper configuration imposed by GemFire/Geode PDX framework and JSONFormatter class.
This commit is contained in:
@@ -19,7 +19,9 @@ import java.math.BigDecimal;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -30,6 +32,7 @@ import lombok.RequiredArgsConstructor;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(staticName = "newLineItem")
|
||||
@SuppressWarnings("unused")
|
||||
public class LineItem {
|
||||
|
||||
@@ -20,8 +20,10 @@ import java.math.BigDecimal;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.gemfire.mapping.annotation.Region;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
@@ -38,6 +40,7 @@ import lombok.ToString;
|
||||
@Getter
|
||||
@ToString(of = "name")
|
||||
@EqualsAndHashCode(of = "name")
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(staticName = "newProduct")
|
||||
@SuppressWarnings("unused")
|
||||
public class Product {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
package example.app.pos.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -42,14 +42,17 @@ import lombok.Getter;
|
||||
* @see org.springframework.data.gemfire.mapping.annotation.Region
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@Getter
|
||||
@Region("PurchaseOrders")
|
||||
@SuppressWarnings("unused")
|
||||
public class PurchaseOrder implements Iterable<LineItem> {
|
||||
|
||||
@Id @Getter
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private final Set<LineItem> lineItems = new LinkedHashSet<>();
|
||||
//@Getter(AccessLevel.PROTECTED) // Ideally! However, Jackson ObjectMapper does not handle protected correctly!
|
||||
// In fact, ideally, no getter at all; why can't Jackson's ObjectMapper handle field mapping(?); argh!
|
||||
private List<LineItem> lineItems = new ArrayList<>();
|
||||
|
||||
public Optional<LineItem> findBy(String productName) {
|
||||
|
||||
@@ -77,7 +80,7 @@ public class PurchaseOrder implements Iterable<LineItem> {
|
||||
|
||||
@NotNull @Override
|
||||
public Iterator<LineItem> iterator() {
|
||||
return Collections.unmodifiableSet(this.lineItems).iterator();
|
||||
return Collections.unmodifiableList(this.lineItems).iterator();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
||||
Reference in New Issue
Block a user