Skip to content

Instantly share code, notes, and snippets.

@akkida746
Created November 7, 2016 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkida746/e804787009b223fc0f0f86a36d03296e to your computer and use it in GitHub Desktop.
Save akkida746/e804787009b223fc0f0f86a36d03296e to your computer and use it in GitHub Desktop.
Enum in java
package com.godiva.batch.util;
public enum ECommerceOrderStatus {
/** A status representing a new order in Locate. */
NEW
{
@Override
public String getStatusName()
{
return "new_order";
}
},
POLLED
{
/** A status representing a new order that been retrieved from Locate. */
@Override
public String getStatusName()
{
return "polled";
}
},
ACCEPTED
{
/** A status representing an order that has been accepted by a fulfilling location. */
@Override
public String getStatusName()
{
return "accepted";
}
},
IN_TRANSIT
{
/** A status representing an order that is on its way to a location to be picked up by a customer. */
@Override
public String getStatusName()
{
return "intransit";
}
},
PICKED
{
/** A status representing an order for which the items have been set aside and reserved. */
@Override
public String getStatusName()
{
return "picked";
}
},
FULFILLED
{
/** A status representing an order that has been fulfilled (picked up or shipped). */
@Override
public String getStatusName()
{
return "fulfilled";
}
};
public abstract String getStatusName();
public static ECommerceOrderStatus createLocateOrderStatus(String status)
{
ECommerceOrderStatus locateOrderStatus = null;
if(status.equalsIgnoreCase("new_order"))
{
locateOrderStatus = ECommerceOrderStatus.NEW;
}
else if(status.equalsIgnoreCase("polled"))
{
locateOrderStatus = ECommerceOrderStatus.POLLED;
}
else if(status.equalsIgnoreCase("accepted"))
{
locateOrderStatus = ECommerceOrderStatus.ACCEPTED;
}
else if(status.equalsIgnoreCase("intransit"))
{
locateOrderStatus = ECommerceOrderStatus.IN_TRANSIT;
}
else if(status.equalsIgnoreCase("picked"))
{
locateOrderStatus = ECommerceOrderStatus.PICKED;
}
return locateOrderStatus;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment