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.event;
019
020 import java.util.EnumSet;
021 import java.util.Set;
022 import java.util.Collections;
023
024
025 /**
026 * Enumerates misc properties of {@link OTTrade}.
027 */
028 public enum TradePropertyEnum {
029
030 /** Trade provides opening price for the day */
031 OPEN (0x01),
032
033 /** Trade provides the high price for the day */
034 HIGH (0x02),
035
036 /** Trade provides the low price for the day */
037 LOW (0x04),
038
039 /** Trade provides the high price for the day */
040 CLOSE (0x08),
041
042 /** Trade updates the last trade price */
043 UPDATE_LAST (0x10),
044
045 /** Set if volume is the updated consolidated volume */
046 UPDATE_VOLUME (0x20),
047
048 /** Trade is the cancel for the previous trade */
049 CANCEL (0x40),
050
051 /** Trade is from an ECN book */
052 FROM_BOOK (0x80);
053
054 public final int code;
055
056 private TradePropertyEnum(int code) {
057 this.code = code;
058 }
059
060 public static final Set<TradePropertyEnum> combine(TradePropertyEnum ... vals) {
061 Set<TradePropertyEnum> set = EnumSet.noneOf(TradePropertyEnum.class);
062
063 for(int i = 0; i < vals.length; i++) {
064 if (set.add(vals[i]) == false) {
065 throw new IllegalArgumentException(
066 "duplicate value: " + vals[i]);
067 }
068 }
069
070 return Collections.unmodifiableSet(set);
071 }
072 }