This file contains hidden or 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
multitenancy: | |
tenants: | |
- | |
name: tenant_1 | |
default: true | |
url: jdbc:mysql://localhost:3306/tenant_1?serverTimezone=UTC | |
username: user | |
password: pass | |
driver-class-name: com.mysql.jdbc.Driver | |
- |
This file contains hidden or 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
public class RobotCommand { | |
private String command; | |
private ArrayList<String> arguments; | |
protected RobotCommand() { | |
this.arguments = new ArrayList<String>(); | |
} | |
public RobotCommand cmd(String command) { |
This file contains hidden or 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
RobotCommand.execute(command -> | |
command.cmd("MOVE") | |
.arg("-from 130") | |
.arg("-to 200") | |
.arg("-speed 5")); |
This file contains hidden or 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
private static final Ingredient TOMATO = new Ingredient("tomato", 2); | |
private static final Ingredient CHEESE = new Ingredient("cheese", 1); | |
private static final Ingredient EGG = new Ingredient("egg", 3); | |
private static final Ingredient BAICON = new Ingredient("baicon", 5); | |
private static final Ingredient BARBACOA_SAUCE = new Ingredient("barbacoa sauce", 2); | |
public static Ingredient tomato() { | |
return TOMATO; | |
} | |
This file contains hidden or 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
public class Pizza { | |
private Ingredient[] ingredients; | |
private Function<Pizza, Pizza> complement; | |
private int basePrice; | |
public static Pizza newPizza(int price, Ingredient... ingredients) { | |
return new Pizza(price, ingredients); | |
} |
This file contains hidden or 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
// The client orders a Barbacoa pizza. The base price of the pizza is 15 dollars. | |
Pizza myOrder = Pizza.newPizza(15, baicon(), cheese(), tomato(), barbacoaSauce()); | |
// The client adds some complements | |
// We are decorating the pizza with complements | |
myOrder.setComplements( | |
Complements::chips, | |
Complements::extraDrink, | |
Complements::iceCream, | |
Complements::cinemaDisccount); |
This file contains hidden or 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
@RestController | |
public class MessageController { | |
@RequestMapping(method = RequestMethod.POST) | |
@JsonView(MessageView.MessageSummary.class) | |
public Message createMessage() { | |
Message m = new Message(); | |
m.setAuthor("John Doe"); | |
m.setContent("I am John Doe"); | |
m.setLikes(0); |
This file contains hidden or 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
public interface MessageView { | |
interface MessageSummary {} | |
interface MessageEntire extends MessageSummary {} | |
} |
This file contains hidden or 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
public class Message { | |
@JsonView(MessageView.MessageSummary.class) | |
private String content; | |
@JsonView(MessageView.MessageSummary.class) | |
private String author; | |
@JsonView(MessageView.MessageEntire.class) | |
private int likes; | |
public String getContent() { |
This file contains hidden or 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
@RestController | |
@RequestMapping("/task") | |
public class TaskController { | |
@RequestMapping(method = RequestMethod.POST) | |
public void createTask(@RequestBody CreateTaskRequest createTaskRequest) { | |
if (TaskType.GROUP.equals(createTaskRequest.getType())) { | |
System.out.println("Creating group task"); | |
} | |