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.Set;
021 import java.util.EnumSet;
022 import java.util.Collections;
023
024 /**
025 * Enumerates misc properties of {@link OTDividend}.
026 */
027 public enum DividendPropertyEnum {
028
029 APPROXIMATE (0x0001),
030 ANNUAL (0x0002),
031 CANADIAN (0x0004),
032 EXTRA (0x0008),
033 FINAL (0x0010),
034 INCREASE (0x0020),
035 SEMIANNUAL (0x0040),
036 STOCK (0x0080),
037 SPECIAL (0x0100);
038
039 public final int code;
040
041 private DividendPropertyEnum(int code) {
042 this.code = code;
043 }
044
045 public static final Set<DividendPropertyEnum> combine(DividendPropertyEnum ... vals) {
046 Set<DividendPropertyEnum> set = EnumSet.noneOf(DividendPropertyEnum.class);
047
048 for(int i = 0; i < vals.length; i++) {
049 if (set.add(vals[i]) == false) {
050 throw new IllegalArgumentException(
051 "duplicate value: " + vals[i]);
052 }
053 }
054
055 return Collections.unmodifiableSet(set);
056 }
057 }