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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>mustache</artifactId>
|
<artifactId>mustache</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>mustache</name>
|
<name>mustache</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spullara.mustache.java</groupId>
|
<groupId>com.github.spullara.mustache.java</groupId>
|
||||||
@ -36,31 +41,6 @@
|
|||||||
|
|
||||||
</dependencies>
|
</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>
|
<properties>
|
||||||
<mustache.compiler.api.version>0.9.2</mustache.compiler.api.version>
|
<mustache.compiler.api.version>0.9.2</mustache.compiler.api.version>
|
||||||
<assertj.version>3.7.0</assertj.version>
|
<assertj.version>3.7.0</assertj.version>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.baeldung.mustache.model;
|
package com.baeldung.mustache.model;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.temporal.Temporal;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class Todo {
|
public class Todo {
|
||||||
|
|
||||||
public Todo(){}
|
public Todo() {
|
||||||
|
}
|
||||||
|
|
||||||
public Todo(String title, String text) {
|
public Todo(String title, String text) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
@ -26,6 +26,7 @@ public class Todo {
|
|||||||
done = true;
|
done = true;
|
||||||
completedOn = new Date();
|
completedOn = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
@ -63,21 +64,13 @@ public class Todo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long doneSince() {
|
public long doneSince() {
|
||||||
if ( done ){
|
return done ? Duration
|
||||||
return Duration.between(createdOn.toInstant(), completedOn.toInstant()).toMinutes();
|
.between(createdOn.toInstant(), completedOn.toInstant())
|
||||||
}
|
.toMinutes() : 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Function<Object, Object> handleDone() {
|
public Function<Object, Object> handleDone() {
|
||||||
return (obj) -> {
|
return (obj) -> done ? String.format("<small>Done %s minutes ago<small>", obj) : "";
|
||||||
if ( done ){
|
|
||||||
return String.format("<small>Done %s minutes ago<small>", obj);
|
|
||||||
}else{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user