Added new ProductState and improved product state machine
This commit is contained in:
parent
4cef005934
commit
1771fc0fdb
@ -71,11 +71,16 @@ public class Product
|
||||
// "State machine methods"
|
||||
|
||||
/**
|
||||
* Set current product state to AVAILABLE
|
||||
* Set current product state to AVAILABLE. Throws IllegalStateException if the product is not IN_ACTION, READY_FOR_RECEPTION or IN_REQUIREMENT.
|
||||
*/
|
||||
public void setStateToAvailable()
|
||||
{
|
||||
this.productState = ProductState.AVAILABLE;
|
||||
if (this.productState.equals(ProductState.IN_ACTION) ||
|
||||
this.productState.equals(ProductState.READY_FOR_RECEPTION) ||
|
||||
this.productState.equals(ProductState.IN_REQUIREMENT))
|
||||
this.productState = ProductState.AVAILABLE;
|
||||
else
|
||||
throw new IllegalStateException("Cannot set state AVAILABLE. Product is not IN_ACTION, READY_FOR_RECEPTION or IN_REQUIREMENT");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,5 +2,5 @@ package cz.cvut.fel.sit.omo.foodchain.product;
|
||||
|
||||
public enum ProductState
|
||||
{
|
||||
AVAILABLE, READY_FOR_DISPATCH, IN_TRANSIT, READY_FOR_RECEPTION, IN_ACTION
|
||||
AVAILABLE, READY_FOR_DISPATCH, IN_TRANSIT, READY_FOR_RECEPTION, IN_ACTION, IN_REQUIREMENT
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user