/*
* Created on Nov 27, 2014
*
* Copyright 2006 ATPCO Confidential and Proprietary. All Rights Reserved.
*/
package com.atpco.textload.processor;
public class TestEnum {
public static void main(String[] args) {
System.out.println(BatchStatusType.FILING_IN_PROGRESS.getName());
System.out.println(BatchStatusType.get(5));
System.out.println(BatchStatusType.get("available_for_filing"));
System.out.println(BatchStatusType.values());
System.out.println(BatchStatusType.getBatchStatusType("AVAILABLE_FOR_FILING"));
}
}
enum BatchStatusType implements FilingDataType {
INCOMPLETE("incomplete",1), AVAILABLE_FOR_FILING("available_for_filing",2), FILING_IN_PROGRESS("filing_in_progress",3), FILED("filed",4), AWAITING_DISTRIBUTION("awaiting_distribution",5), DISTRIBUTION_IN_PROGRESS("distribution_in_progress",6), DISTRIBUTED("distributed",7);
private int code;
private String name;
private BatchStatusType(String name,int code){
this.name=name;
this.code=code;
}
public Integer getCode() {
return Integer.valueOf(this.code);
}
public String getName() {
return this.name;
}
public static String get(Integer code) {
for (BatchStatusType e : values()) {
if (e.getCode().equals(code)) {
return e.getName();
}
}
return null;
}
public static Integer get(String name) {
for (BatchStatusType e : values()) {
if (e.getName().equals(name)) {
return e.getCode();
}
}
return null;
}
public static BatchStatusType getBatchStatusType(final String batchStatusTypeString){
final BatchStatusType[] allTypes=BatchStatusType.values();
for(final BatchStatusType batchStatusType:allTypes){
if(batchStatusType.getValue().equals(batchStatusTypeString)){
return batchStatusType;
}
}
return null;
}
public boolean isEquals(BatchStatusType batchStatusType) {
return equals(batchStatusType);
}
@Override
public String getValue() {
return this.toString();
}
}
interface FilingDataType {
String getValue();
}