Mustache refactor (#1889)
This commit is contained in:
parent
cfc44ecbb6
commit
3a34f906a2
|
@ -2,12 +2,17 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>mustache</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>mustache</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.spullara.mustache.java</groupId>
|
||||
|
@ -36,31 +41,6 @@
|
|||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<mustache.compiler.api.version>0.9.2</mustache.compiler.api.version>
|
||||
<assertj.version>3.7.0</assertj.version>
|
||||
|
|
|
@ -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<Object, Object> handleDone(){
|
||||
return (obj) -> {
|
||||
if ( done ){
|
||||
return String.format("<small>Done %s minutes ago<small>", obj);
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
public Function<Object, Object> handleDone() {
|
||||
return (obj) -> done ? String.format("<small>Done %s minutes ago<small>", obj) : "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue