Hello I have an enum
of months.
public enum Months{
JANUARY, FEBUARY, MARCH,
APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER;
}
In the service I have a method that should only work if the month is greater than MARCH
i.e. APRIL, MAY, ....
. How can I write the following line more eloquently:
public void monthCheck(Object object){
if (object.month!= Months.JANUARY || object.month!= Months.FEBUARY || object.month != Months.MARCH){
//do something here
}
}
Edit: I can not use ordinal because I have other use cases like:
If I have enum of stasuses PENDING, PREPARING, PREPARED, DELIEVERED, COMPLETED, RETURNED. And I only want to show orders with statuses DELIEVERED, COMPLETED or RETURNED. I want to write a method like that only return if the status is either of DELIEVERED, COMPLETED or RETURNED
if (order.getStatus()=={DELIEVERED, COMPLETED or RETURNED})
{return order}
else{
throw new exception ("not valid status at this point");
}```