Skip to content

Instantly share code, notes, and snippets.

View HDBandit's full-sized avatar

Gerard Vico HDBandit

View GitHub Profile
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
-
public class RobotCommand {
private String command;
private ArrayList<String> arguments;
protected RobotCommand() {
this.arguments = new ArrayList<String>();
}
public RobotCommand cmd(String command) {
RobotCommand.execute(command ->
command.cmd("MOVE")
.arg("-from 130")
.arg("-to 200")
.arg("-speed 5"));
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;
}
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);
}
// 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);
@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);
public interface MessageView {
interface MessageSummary {}
interface MessageEntire extends MessageSummary {}
}
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() {
@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");
}