2017-11-14 3 views
0

restbucksプロジェクトでは、オーダーに広告申込情報のプライベートリストがあります。私は、単一の注文を取得するときに、このフィールドが残りのAPIを介してどのように公開されているか把握できません。パブリックゲッターや何も持っていません。ミックスインですか?オーダー明細はどのように公開されますか?

答えて

0

@Data@NoArgsConstructor@AllArgsConstructor@EqualsAndHashCodeは定型コードを自動生成するために使用されるLombok annotationsです。

@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); 
    } 
} 

あなたはdelomboked 1(ロンボク島・低速運行クラブへようこそ))でこのコードを比較することができます:オーダーエンティティに、私が見

@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

@Getterをすべてのフィールドにパブリックゲッターを追加し、ラインアイテムは、excerptProjectionを使用してコレクションリソースに隠されます。あなたはほぼ正しいです。 – aycanadal

関連する問題