001 package biweekly.property; 002 003 import java.util.Arrays; 004 import java.util.Collection; 005 006 /* 007 Copyright (c) 2013, Michael Angstadt 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without 011 modification, are permitted provided that the following conditions are met: 012 013 1. Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 2. Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 026 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030 031 /** 032 * <p> 033 * Defines the type of action to invoke when an alarm is triggered. 034 * </p> 035 * 036 * <p> 037 * <b>Examples:</b> 038 * 039 * <pre class="brush:java"> 040 * //creating a new property 041 * Action action = Action.audio(); 042 * 043 * if (action.isAudio()) { 044 * //it's an "AUDIO" alarm 045 * } 046 * </pre> 047 * 048 * </p> 049 * @author Michael Angstadt 050 * @rfc 5545 p.132-3 051 */ 052 public class Action extends EnumProperty { 053 private static final String AUDIO = "AUDIO"; 054 private static final String DISPLAY = "DISPLAY"; 055 private static final String EMAIL = "EMAIL"; 056 057 /** 058 * Creates an action property. Use of this constructor is discouraged and 059 * may put the property in an invalid state. Use one of the static factory 060 * methods instead. 061 * @param value the value (e.g. "AUDIO") 062 */ 063 public Action(String value) { 064 super(value); 065 } 066 067 /** 068 * Creates an "audio" action property. 069 * @return the property 070 */ 071 public static Action audio() { 072 return create(AUDIO); 073 } 074 075 /** 076 * Determines if this property is an "audio" action. 077 * @return true if it's an "audio" action, false if not 078 */ 079 public boolean isAudio() { 080 return is(AUDIO); 081 } 082 083 /** 084 * Creates an "display" action property. 085 * @return the property 086 */ 087 public static Action display() { 088 return create(DISPLAY); 089 } 090 091 /** 092 * Determines if this property is an "display" action. 093 * @return true if it's an "display" action, false if not 094 */ 095 public boolean isDisplay() { 096 return is(DISPLAY); 097 } 098 099 /** 100 * Creates an "email" action property. 101 * @return the property 102 */ 103 public static Action email() { 104 return create(EMAIL); 105 } 106 107 /** 108 * Determines if this property is an "email" action. 109 * @return true if it's an "email" action, false if not 110 */ 111 public boolean isEmail() { 112 return is(EMAIL); 113 } 114 115 private static Action create(String value) { 116 return new Action(value); 117 } 118 119 @Override 120 protected Collection<String> getStandardValues() { 121 return Arrays.asList(AUDIO, DISPLAY, EMAIL); 122 } 123 }