View Javadoc

1   /*
2    *  Copyright 2001-2013 Stephen Colebourne
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.joda.beans;
17  
18  /**
19   * An enumeration of read-write property types.
20   * <p>
21   * A property may be read-only, read-write or write-only.
22   * This enumeration models those options.
23   * 
24   * @author Stephen Colebourne
25   */
26  public enum PropertyReadWrite {
27  
28      /**
29       * The property can be read and written.
30       */
31      READ_WRITE(),
32      /**
33       * The property is read-only.
34       */
35      READ_ONLY(),
36      /**
37       * The property is write-only.
38       */
39      WRITE_ONLY();
40  
41      //-----------------------------------------------------------------------
42      /**
43       * Checks whether the property is readable.
44       * 
45       * @return true if the property can be read
46       */
47      public boolean isReadable() {
48          return this != WRITE_ONLY;
49      }
50  
51      /**
52       * Checks whether the property is writable.
53       * 
54       * @return true if the property can be written
55       */
56      public boolean isWritable() {
57          return this != READ_ONLY;
58      }
59  
60  }