I have the following POJO class:
@Value
@Builder
@RequiredArgsConstructor
public class XYZ {
@NonNull
private final String a;
@NonNull
private final Map<Integer, ABC> items;
@NonNull
private final State state;
public enum State {
STARTED,
INPROGRESS,
STOPPED
}
}
Now, in this, based on different sizes of the map, I wanted to change the value of state field. Eg. When size is 0, then state should be STOPPED and when it is less than 5 and more than 0, then it is INPROGRESS and if it is more than 5, then it should be STARTED.
What is the best way to do this? Should this logic lie inside this POJO or should I explicitly check this whenever I am making change in map explicitly. How can I do it properly? Any ideas?
Aucun commentaire:
Enregistrer un commentaire