Skip to content

Commit 5aed7b3

Browse files
committed
Refactor history
1 parent fb6d536 commit 5aed7b3

7 files changed

Lines changed: 32 additions & 31 deletions

File tree

patternfx-core/src/main/java/com/techsenger/patternfx/core/ComponentHistory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
public interface ComponentHistory extends Serializable {
2828

2929
/**
30-
* Returns whether this history instance is fresh, meaning it was newly created and has not yet been used to
31-
* save or restore any component state. A fresh history contains no previously stored data and should not be
30+
* Returns whether this history instance is new, meaning it was newly created and has not yet been used to
31+
* save or restore any component state. A new history contains no previously stored data and should not be
3232
* passed to a component for restoration.
3333
*
3434
* <p>Once the component's state has been saved into this history, the flag becomes {@code false}, indicating that
3535
* the history now holds valid data that can be used to restore the component's state in future instances.
3636
*
37-
* @return {@code true} if this history is fresh and has not yet been used, {@code false} otherwise
37+
* @return {@code true} if this history is new and has not yet been used, {@code false} otherwise
3838
*/
39-
boolean isFresh();
39+
boolean isNew();
4040

4141
/**
4242
* Method called before the component is serialized. This can be used to prepare the object's state

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/AbstractHistory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
*/
2525
public abstract class AbstractHistory implements ComponentHistory {
2626

27-
private boolean fresh = true;
27+
private boolean isNew = true;
2828

2929
@Override
30-
public boolean isFresh() {
31-
return fresh;
30+
public boolean isNew() {
31+
return isNew;
3232
}
3333

3434
@Override
@@ -41,7 +41,7 @@ public void preSerialize() {
4141

4242
}
4343

44-
void setFresh(boolean fresh) {
45-
this.fresh = fresh;
44+
void setNew(boolean value) {
45+
this.isNew = value;
4646
}
4747
}

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/AbstractPresenter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ protected final void restoreHistory() {
161161
var policy = getHistoryPolicy();
162162
logger.debug("{} History policy during restore: {}", getDescriptor().getLogPrefix(), policy);
163163
if (policy != NONE) {
164-
if (history.isFresh()) {
165-
logger.debug("{} History is fresh. Skipping restoration", getDescriptor().getLogPrefix());
164+
if (history.isNew()) {
165+
logger.debug("{} History is new. Skipping restoration", getDescriptor().getLogPrefix());
166166
} else {
167167
switch (policy) {
168168
case DATA:
@@ -223,7 +223,7 @@ protected final void saveHistory() {
223223
*
224224
*/
225225
protected void saveData() {
226-
getHistory().setFresh(false);
226+
getHistory().setNew(false);
227227
}
228228

229229
/**
@@ -232,7 +232,7 @@ protected void saveData() {
232232
*
233233
*/
234234
protected void saveAppearance() {
235-
getHistory().setFresh(false);
235+
getHistory().setNew(false);
236236
}
237237

238238
protected abstract Descriptor createDescriptor();

patternfx-mvvm/src/main/java/com/techsenger/patternfx/mvvm/AbstractHistory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
*/
2525
public abstract class AbstractHistory implements ComponentHistory {
2626

27-
private boolean fresh = true;
27+
private boolean isNew = true;
2828

2929
@Override
30-
public boolean isFresh() {
31-
return fresh;
30+
public boolean isNew() {
31+
return isNew;
3232
}
3333

3434
@Override
@@ -41,7 +41,7 @@ public void preSerialize() {
4141

4242
}
4343

44-
void setFresh(boolean fresh) {
45-
this.fresh = fresh;
44+
void setNew(boolean value) {
45+
this.isNew = value;
4646
}
4747
}

patternfx-mvvm/src/main/java/com/techsenger/patternfx/mvvm/AbstractViewModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ protected final void restoreHistory() {
101101
var policy = getHistoryPolicy();
102102
logger.debug("{} History policy during restore: {}", getDescriptor().getLogPrefix(), policy);
103103
if (policy != NONE) {
104-
if (history.isFresh()) {
105-
logger.debug("{} History is fresh. Skipping restoration", getDescriptor().getLogPrefix());
104+
if (history.isNew()) {
105+
logger.debug("{} History is new. Skipping restoration", getDescriptor().getLogPrefix());
106106
} else {
107107
switch (policy) {
108108
case DATA:
@@ -175,7 +175,7 @@ protected final void saveHistory() {
175175
* @param viewModel
176176
*/
177177
protected void saveData() {
178-
getHistory().setFresh(false);
178+
getHistory().setNew(false);
179179
}
180180

181181
/**
@@ -185,7 +185,7 @@ protected void saveData() {
185185
* @param viewModel
186186
*/
187187
protected void saveAppearance() {
188-
getHistory().setFresh(false);
188+
getHistory().setNew(false);
189189
}
190190

191191
protected abstract Descriptor createDescriptor();

patternfx-mvvmx/src/main/java/com/techsenger/patternfx/mvvmx/AbstractComponentViewModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ protected final void restoreHistory() {
9595
var policy = getHistoryPolicy();
9696
logger.debug("{} History policy during restore: {}", getMediator().getLogPrefix(), policy);
9797
if (policy != NONE) {
98-
if (history.isFresh()) {
99-
logger.debug("{} History is fresh. Skipping restoration", getMediator().getLogPrefix());
98+
if (history.isNew()) {
99+
logger.debug("{} History is new. Skipping restoration", getMediator().getLogPrefix());
100100
} else {
101101
switch (policy) {
102102
case DATA:
@@ -169,7 +169,7 @@ protected final void saveHistory() {
169169
* @param viewModel
170170
*/
171171
protected void saveData() {
172-
getHistory().setFresh(false);
172+
getHistory().setNew(false);
173173
}
174174

175175
/**
@@ -179,7 +179,7 @@ protected void saveData() {
179179
* @param viewModel
180180
*/
181181
protected void saveAppearance() {
182-
getHistory().setFresh(false);
182+
getHistory().setNew(false);
183183
}
184184

185185
void prepareHistory() {

patternfx-mvvmx/src/main/java/com/techsenger/patternfx/mvvmx/AbstractHistory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
*/
2525
public abstract class AbstractHistory implements ComponentHistory {
2626

27-
private boolean fresh = true;
27+
private boolean isNew = true;
2828

29-
public boolean isFresh() {
30-
return fresh;
29+
@Override
30+
public boolean isNew() {
31+
return isNew;
3132
}
3233

3334
@Override
@@ -40,7 +41,7 @@ public void preSerialize() {
4041

4142
}
4243

43-
void setFresh(boolean fresh) {
44-
this.fresh = fresh;
44+
void setNew(boolean value) {
45+
this.isNew = value;
4546
}
4647
}

0 commit comments

Comments
 (0)