001    /**
002     * Copyright 2007 Mike Kroutikov.
003     *
004     * This program is free software; you can redistribute it and/or modify
005     *   it under the terms of the Lesser GNU General Public License as 
006     *   published by the Free Software Foundation; either version 3 of
007     *   the License, or (at your option) any later version.
008     *
009     *   This program is distributed in the hope that it will be useful,
010     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
011     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     *   Lesser GNU General Public License for more details.
013     *
014     *   You should have received a copy of the Lesser GNU General Public License
015     *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
016     */
017    
018    package org.otfeed.command;
019    
020    import java.util.HashMap;
021    import java.util.Map;
022    
023    import org.otfeed.event.OTBookDelete;
024    
025    /**
026     * Enumerates possible types for the {@link OTBookDelete}
027     * event.
028     * 
029     * @see OTBookDelete
030     */
031    public enum BookDeleteTypeEnum {
032    
033            /** Order delete */
034            ORDER           ('1'), 
035    
036            /** Previous delete */
037            PREVIOUS        ('2'), 
038            
039            /** Delete of all */
040            ALL                     ('3'), 
041            
042            /** After delete */
043            AFTER           ('A');
044            
045            public final int code;
046            
047            private BookDeleteTypeEnum(int code) {
048                    this.code = code;
049            }
050            
051            public final static Map<Integer,BookDeleteTypeEnum> decoder
052                            = new HashMap<Integer,BookDeleteTypeEnum>();
053            static {
054                    BookDeleteTypeEnum []v = values();
055                    for(int i = 0; i < v.length; i++) {
056                            if(decoder.put(v[i].code, v[i]) != null) {
057                                    throw new AssertionError("duplicate book delete type code for: " + v[i]);
058                            }
059                    }
060            }
061    }