From 3a34f906a258659102d1017bdef5a0257a02478d Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 21 May 2017 16:24:50 +0200 Subject: [PATCH] Mustache refactor (#1889) --- mustache/pom.xml | 32 +++---------- .../com/baeldung/mustache/model/Todo.java | 45 ++++++++----------- 2 files changed, 25 insertions(+), 52 deletions(-) diff --git a/mustache/pom.xml b/mustache/pom.xml index 8916b196f0..d5d80b58e9 100644 --- a/mustache/pom.xml +++ b/mustache/pom.xml @@ -2,12 +2,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.baeldung mustache 0.0.1-SNAPSHOT jar mustache + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + com.github.spullara.mustache.java @@ -36,31 +41,6 @@ - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*IntegrationTest.java - **/*LiveTest.java - - - - - - 0.9.2 3.7.0 diff --git a/mustache/src/main/java/com/baeldung/mustache/model/Todo.java b/mustache/src/main/java/com/baeldung/mustache/model/Todo.java index c329045876..cf845a3227 100644 --- a/mustache/src/main/java/com/baeldung/mustache/model/Todo.java +++ b/mustache/src/main/java/com/baeldung/mustache/model/Todo.java @@ -1,31 +1,32 @@ package com.baeldung.mustache.model; import java.time.Duration; -import java.time.temporal.Temporal; import java.util.Date; import java.util.function.Function; public class Todo { - public Todo(){} - - public Todo(String title, String text){ + public Todo() { + } + + public Todo(String title, String text) { this.title = title; this.text = text; createdOn = new Date(); } - + private String title; private String text; private boolean done = false; - + private Date createdOn; private Date completedOn; - - public void markAsDone(){ + + public void markAsDone() { done = true; completedOn = new Date(); } + public String getTitle() { return title; } @@ -61,24 +62,16 @@ public class Todo { public void setCompletedOn(Date completedOn) { this.completedOn = completedOn; } - - public long doneSince(){ - if ( done ){ - return Duration.between(createdOn.toInstant(), completedOn.toInstant()).toMinutes(); - } - return 0; + + public long doneSince() { + return done ? Duration + .between(createdOn.toInstant(), completedOn.toInstant()) + .toMinutes() : 0; } - - public Function handleDone(){ - return (obj) -> { - if ( done ){ - return String.format("Done %s minutes ago", obj); - }else{ - return ""; - } - - }; - + + public Function handleDone() { + return (obj) -> done ? String.format("Done %s minutes ago", obj) : ""; + } - + }