First Implementation
public enum ReviewFlowExample {
Draft {
@Override
public ReviewFlowExample getNext() {
return Review;
}
@Override
public ReviewFlowExample getPrevious() {
return null;
}
},
Review {
@Override
public ReviewFlowExample getNext() {
return Final;
}
@Override
public ReviewFlowExample getPrevious() {
return Draft;
}
},
Final {
@Override
public ReviewFlowExample getNext() {
return null;
}
@Override
public ReviewFlowExample getPrevious() {
return Review;
}
};
public abstract ReviewFlowExample getNext();
public abstract ReviewFlowExample getPrevious();
public boolean isDraft() {
return this.equals(Draft);
}
}
Second Implemenation
public enum ReviewFlowExample {
Draft,
Review,
Final;
private ReviewFlowExample next;
private ReviewFlowExample previous;
static{
Draft.setNext(Review);
Review.setNext(Final);
Review.setPrevious(Draft);
Final.setPrevious(Review);
}
private ReviewFlowExample(){
}
public ReviewFlowExample getNext(){
return next;
}
public ReviewFlowExample getPrevious(){
return previous;
}
private void setNext(ReviewFlowExample next){
this.next = next;
}
private void setPrevious(ReviewFlowExample previous){
this.previous = previous;
}
public boolean isDraft(){
return this == Draft;
}
}
getNextState()
and so on)? \$\endgroup\$null
as it is in the second example. \$\endgroup\$