Reputation: 147
I'm developing a simple system for parcel service. I don't fully grasp on how to do this part when setting status of the parcel. When you login you can see all available orders. As a courier you can mark new orders as "accepted" or "rejected". You can mark "accepted" orders as "in transit". And "in transit" orders you can mark as "delivered" or "failed to deliver". My question is do I need to create a field "status" and every time set some kind of string, or I should do a boolean field? By the way, if I would "reject" an order. How could I 'remember' that this particular courier has already rejected that particular oder and do not show it to him? Thank you for your ideas.
Upvotes: 0
Views: 1615
Reputation: 7689
You can make the enum as an inner static class. Its simpler and faster because you do not have to create an object of ORDER_STATUS.
public class Order {
private final String id;
private final String name;
private final ORDER_STATUS order_status;
public static enum ORDER_STATUS {
ACCEPTED,REJECTED,DELIVERED,FAILED_TO_DELIVER,REJECT;
}
}
Upvotes: 2
Reputation: 4045
Create an Enum and define a variable of that type in your Order object and your business logic should do the setting and interpreting the enum values in your application.
public enum ORDER_STATUS {
ACCEPTED,REJECTED,DELIVERED,FAILED_TO_DELIVER,REJECT;
}
public class Order {
private Long id;
private ORDER_STATUS orderStatus;
}
Upvotes: 2