001 package biweekly.property;
002
003 /*
004 Copyright (c) 2013, Michael Angstadt
005 All rights reserved.
006
007 Redistribution and use in source and binary forms, with or without
008 modification, are permitted provided that the following conditions are met:
009
010 1. Redistributions of source code must retain the above copyright notice, this
011 list of conditions and the following disclaimer.
012 2. Redistributions in binary form must reproduce the above copyright notice,
013 this list of conditions and the following disclaimer in the documentation
014 and/or other materials provided with the distribution.
015
016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
020 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026 */
027
028 /**
029 * <p>
030 * Defines whether an event is visible to free/busy time searches. If an event
031 * does not have this property, the event should be considered visible
032 * ("opaque").
033 * </p>
034 * <p>
035 * <b>Examples:</b>
036 *
037 * <pre>
038 * Transparency transp = Transparency.opaque();
039 *
040 * if (transp.isOpaque()) {
041 * ...
042 * }
043 * </pre>
044 *
045 * </p>
046 * @author Michael Angstadt
047 * @see <a href="http://tools.ietf.org/html/rfc5545#page-101">RFC 5545
048 * p.101-2</a>
049 */
050 public class Transparency extends TextProperty {
051 private static final String OPAQUE = "OPAQUE";
052 private static final String TRANSPARENT = "TRANSPARENT";
053
054 /**
055 * Creates a new transparency property.
056 * @param value the value
057 */
058 public Transparency(String value) {
059 super(value);
060 }
061
062 /**
063 * Creates a property that marks the event as being visible to free/busy
064 * time searches.
065 * @return the property
066 */
067 public static Transparency opaque() {
068 return create(OPAQUE);
069 }
070
071 /**
072 * Determines if the event is visible to free/busy time searches.
073 * @return true if it's visible, false if not
074 */
075 public boolean isOpaque() {
076 return is(OPAQUE);
077 }
078
079 /**
080 * Creates a property that marks the event as being hidden from free/busy
081 * time searches.
082 * @return the property
083 */
084 public static Transparency transparent() {
085 return create(TRANSPARENT);
086 }
087
088 /**
089 * Determines if the event is hidden from free/busy time searches.
090 * @return true if it's hidden, false if not
091 */
092 public boolean isTransparent() {
093 return is(TRANSPARENT);
094 }
095
096 private static Transparency create(String value) {
097 return new Transparency(value);
098 }
099
100 private boolean is(String value) {
101 return value.equalsIgnoreCase(this.value);
102 }
103 }