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 whether an event is visible to free/busy time searches. If an event
034 * does not have this property, the event should be considered visible
035 * ("opaque").
036 * </p>
037 * <p>
038 * <b>Examples:</b>
039 *
040 * <pre class="brush:java">
041 * //creating a new property
042 * Transparency transp = Transparency.opaque();
043 *
044 * if (transp.isOpaque()) {
045 * //its value is "OPAQUE"
046 * }
047 *
048 * //usage in a VEVENT component
049 * VEvent event = ...
050 * event.setTransparency(true); //hidden from searches ("TRANSPARENT")
051 * event.setTransparency(false); //visible to searches ("OPAQUE")
052 * </pre>
053 *
054 * </p>
055 * @author Michael Angstadt
056 * @rfc 5545 p.101-2
057 */
058 public class Transparency extends EnumProperty {
059 private static final String OPAQUE = "OPAQUE";
060 private static final String TRANSPARENT = "TRANSPARENT";
061
062 /**
063 * Creates a new transparency property.
064 * @param value the value
065 */
066 public Transparency(String value) {
067 super(value);
068 }
069
070 /**
071 * Creates a property that marks the event as being visible to free/busy
072 * time searches.
073 * @return the property
074 */
075 public static Transparency opaque() {
076 return create(OPAQUE);
077 }
078
079 /**
080 * Determines if the event is visible to free/busy time searches.
081 * @return true if it's visible, false if not
082 */
083 public boolean isOpaque() {
084 return is(OPAQUE);
085 }
086
087 /**
088 * Creates a property that marks the event as being hidden from free/busy
089 * time searches.
090 * @return the property
091 */
092 public static Transparency transparent() {
093 return create(TRANSPARENT);
094 }
095
096 /**
097 * Determines if the event is hidden from free/busy time searches.
098 * @return true if it's hidden, false if not
099 */
100 public boolean isTransparent() {
101 return is(TRANSPARENT);
102 }
103
104 private static Transparency create(String value) {
105 return new Transparency(value);
106 }
107
108 @Override
109 protected Collection<String> getStandardValues() {
110 return Arrays.asList(OPAQUE, TRANSPARENT);
111 }
112 }