Skip to content

Commit bf8d812

Browse files
committed
GP-66 minor fixes and naming updates
1 parent 1f8ce31 commit bf8d812

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
package com.bobocode.mvc.data;
22

3-
43
import com.bobocode.mvc.model.Note;
54
import org.springframework.stereotype.Component;
65

76
import java.time.LocalDate;
7+
import java.time.LocalDateTime;
88
import java.util.*;
99

1010
@Component
1111
public class Notes {
12-
private final Map<UUID, Note> notes = new LinkedHashMap<>();
12+
private final Map<UUID, Note> notesMap = new HashMap<>();
1313

1414
public List<Note> getAll(){
15-
return new ArrayList<>(notes.values());
15+
var noteList = new ArrayList<>(notesMap.values());
16+
noteList.sort(Comparator.comparing(Note::getCreatedOn));
17+
return noteList;
1618
}
1719

1820
public void add(Note note) {
1921
note.setId(UUID.randomUUID());
20-
note.setCreationDate(LocalDate.now());
21-
notes.put(note.getId(), note);
22+
note.setCreatedOn(LocalDateTime.now());
23+
notesMap.put(note.getId(), note);
2224
}
2325
}

3-0-spring-framework/3-0-1-hello-spring-mvc/src/main/java/com/bobocode/mvc/model/Note.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.NonNull;
66

77
import java.time.LocalDate;
8+
import java.time.LocalDateTime;
89
import java.util.UUID;
910

1011
@Data
@@ -15,7 +16,7 @@ public class Note {
1516
private String title;
1617
@NonNull
1718
private String text;
18-
private LocalDate creationDate;
19+
private LocalDateTime createdOn;
1920

2021
public Note(String title, String text) {
2122
this.title = title;

3-0-spring-framework/3-0-1-hello-spring-mvc/src/main/resources/templates/notes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1 class="title">My notes</h1>
3131
<div class="note" th:each="theNote : ${noteList}">
3232
<div class="title_note" th:text="${theNote.title}">The title</div>
3333
<div class="text_note" th:text="${theNote.text}">The text of very long story, or just shopping list</div>
34-
<div class="date_note" th:text="${theNote.creationDate}">23.04.2021</div>
34+
<div class="date_note" th:text="${theNote.createdOn.toLocalDate()}">23.04.2021</div>
3535
</div>
3636
</div>
3737

0 commit comments

Comments
 (0)