Mustache refactor (#1889)
This commit is contained in:
committed by
GitHub
parent
cfc44ecbb6
commit
3a34f906a2
@@ -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) : "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user