2017-11-14 4 views
0

Im Projekt restbucks hat eine Bestellung eine private Liste mit Werbebuchungen. Ich kann nicht herausfinden, wie dieses Feld über Rest-API angezeigt wird, wenn man eine einzelne Bestellung bekommt. Es hat keinen öffentlichen Getter oder so etwas. Sind es die Mixins?Wie werden Bestellposten angezeigt?

Antwort

0

@Data, @NoArgsConstructor, @AllArgsConstructor, @EqualsAndHashCodeLombok annotations sind, das verwendet werden einen Textcode automatisch generieren.

@Data 
@Entity 
@NoArgsConstructor(force = true) 
@AllArgsConstructor 
@EqualsAndHashCode(callSuper = false) 
public class LineItem extends AbstractEntity { 

    private final String name; 
    private final int quantity; 
    private final Milk milk; 
    private final Size size; 
    private final MonetaryAmount price; 

    public LineItem(String name, MonetaryAmount price) { 
    this(name, 1, Milk.SEMI, Size.LARGE, price); 
    } 
} 

können Sie diesen Code mit delomboked ein Vergleich (Willkommen zu Lombok-Spaße Club)):

@Entity 
public class LineItem extends AbstractEntity { 

    private final String name; 
    private final int quantity; 
    private final Milk milk; 
    private final Size size; 
    private final MonetaryAmount price; 

    public LineItem(String name, MonetaryAmount price) { 
     this(name, 1, Milk.SEMI, Size.LARGE, price); 
    } 

    public LineItem(String name, int quantity, Milk milk, Size size, MonetaryAmount price) { 
     this.name = name; 
     this.quantity = quantity; 
     this.milk = milk; 
     this.size = size; 
     this.price = price; 
    } 

    public LineItem() { 
     this.name = null; 
     this.quantity = 0; 
     this.milk = null; 
     this.size = null; 
     this.price = null; 
    } 

    public String getName() { 
     return this.name; 
    } 

    public int getQuantity() { 
     return this.quantity; 
    } 

    public Milk getMilk() { 
     return this.milk; 
    } 

    public Size getSize() { 
     return this.size; 
    } 

    public MonetaryAmount getPrice() { 
     return this.price; 
    } 

    public String toString() { 
     return "LineItem(name=" + this.getName() + ", quantity=" + this.getQuantity() + ", milk=" + this.getMilk() + ", size=" + this.getSize() + ", price=" + this.getPrice() + ")"; 
    } 

    public boolean equals(Object o) { 
     if (o == this) return true; 
     if (!(o instanceof LineItem)) return false; 
     final LineItem other = (LineItem) o; 
     if (!other.canEqual((Object) this)) return false; 
     final Object this$name = this.getName(); 
     final Object other$name = other.getName(); 
     if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false; 
     if (this.getQuantity() != other.getQuantity()) return false; 
     final Object this$milk = this.getMilk(); 
     final Object other$milk = other.getMilk(); 
     if (this$milk == null ? other$milk != null : !this$milk.equals(other$milk)) return false; 
     final Object this$size = this.getSize(); 
     final Object other$size = other.getSize(); 
     if (this$size == null ? other$size != null : !this$size.equals(other$size)) return false; 
     final Object this$price = this.getPrice(); 
     final Object other$price = other.getPrice(); 
     if (this$price == null ? other$price != null : !this$price.equals(other$price)) return false; 
     return true; 
    } 

    public int hashCode() { 
     final int PRIME = 59; 
     int result = 1; 
     final Object $name = this.getName(); 
     result = result * PRIME + ($name == null ? 43 : $name.hashCode()); 
     result = result * PRIME + this.getQuantity(); 
     final Object $milk = this.getMilk(); 
     result = result * PRIME + ($milk == null ? 43 : $milk.hashCode()); 
     final Object $size = this.getSize(); 
     result = result * PRIME + ($size == null ? 43 : $size.hashCode()); 
     final Object $price = this.getPrice(); 
     result = result * PRIME + ($price == null ? 43 : $price.hashCode()); 
     return result; 
    } 

    protected boolean canEqual(Object other) { 
     return other instanceof LineItem; 
    } 
} 
+0

ich sehe, @Getter auf Bestellung Unternehmen fügt die öffentlichen Getter zu allen Bereichen, und dann die Linie Elemente sind auf der Sammlungsressource mit einem AuszugProjektion ausgeblendet. Sie sind fast richtig, Sir. – aycanadal

Verwandte Themen