Subversion Repositories SmartDukaan

Rev

Rev 554 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.utils;

import java.util.HashMap;
import java.util.Map;

public enum ErrorCodes {
        
        
        
        ERROR_SUCCESS(0),
        /*
         * Thrift exception ErrorCodes
         */
        ERROR_CONNECTION_FAILURE(1),
        /**
         * UserContextService Errors
         */
        ERROR_PARAM_NULL(2),
        ERROR_ADDRESS_EXISTS(3),
        ERROR_USER_NOT_FOUND(4),
        ERROR_MULTIPLE_ENTRIES_FOUND(5)
        
        ;
        
        private final int value;
        
        private ErrorCodes(int value){
                this.value = value;
        }
        
        public int getValue(){
                return this.value;
        }
        
        private static final Map<Integer, ErrorCodes> BY_VALUE = new HashMap<Integer,ErrorCodes>() {{
                for(ErrorCodes val : ErrorCodes.values()) {
                        put(val.getValue(), val);
                        }
        }};
        
        public static ErrorCodes findByValue(int value) { 
                return BY_VALUE.get(value);
        }
}