forked from microservices-patterns/ftgo-application
-
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.
microservices-patterns#51 Replace shared API classes with codegen fro…
…m OpenAPI/JSON schema - Used JSON schema for Restaurant events in Kitchen Service
- Loading branch information
Showing
7 changed files
with
118 additions
and
13 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
67 changes: 67 additions & 0 deletions
67
...itchen-service/src/main/java/net/chrisrichardson/ftgo/kitchenservice/domain/MenuItem.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,67 @@ | ||
package net.chrisrichardson.ftgo.kitchenservice.domain; | ||
|
||
import net.chrisrichardson.ftgo.common.Money; | ||
import org.apache.commons.lang.builder.EqualsBuilder; | ||
import org.apache.commons.lang.builder.HashCodeBuilder; | ||
import org.apache.commons.lang.builder.ToStringBuilder; | ||
|
||
import javax.persistence.Access; | ||
import javax.persistence.AccessType; | ||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
@Access(AccessType.FIELD) | ||
public class MenuItem { | ||
|
||
private String id; | ||
private String name; | ||
private Money price; | ||
|
||
private MenuItem() { | ||
} | ||
|
||
public MenuItem(String id, String name, Money price) { | ||
this.id = id; | ||
this.name = name; | ||
this.price = price; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return EqualsBuilder.reflectionEquals(this, o); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return HashCodeBuilder.reflectionHashCode(this); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Money getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(Money price) { | ||
this.price = price; | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...-service/src/main/java/net/chrisrichardson/ftgo/kitchenservice/domain/RestaurantMenu.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,15 @@ | ||
package net.chrisrichardson.ftgo.kitchenservice.domain; | ||
|
||
import java.util.List; | ||
|
||
public class RestaurantMenu { | ||
private List<MenuItem> menuItems; | ||
|
||
public RestaurantMenu(List<MenuItem> menuItems) { | ||
this.menuItems = menuItems; | ||
} | ||
|
||
public List<MenuItem> getMenuItems() { | ||
return menuItems; | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...n/java/net/chrisrichardson/ftgo/kitchenservice/messagehandlers/RestaurantEventMapper.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,15 @@ | ||
package net.chrisrichardson.ftgo.kitchenservice.messagehandlers; | ||
|
||
import net.chrisrichardson.ftgo.common.Money; | ||
import net.chrisrichardson.ftgo.restaurantservice.events.MenuItem; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class RestaurantEventMapper { | ||
|
||
public static List<net.chrisrichardson.ftgo.kitchenservice.domain.MenuItem> toMenuItems(List<MenuItem> menuItems) { | ||
return menuItems.stream().map(mi -> new net.chrisrichardson.ftgo.kitchenservice.domain.MenuItem(mi.getId(), mi.getName(), new Money(mi.getPrice()))).collect(Collectors.toList()); | ||
} | ||
|
||
} |