View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.beanutils;
19  
20  
21  
22  
23  
24  /**
25   * <p>A specialized extension to <code>DynaClass</code> that allows properties
26   * to be added or removed dynamically.</p>
27   *
28   * <p><strong>WARNING</strong> - No guarantees that this will be in the final
29   * APIs ... it's here primarily to preserve some concepts that were in the
30   * original proposal for further discussion.</p>
31   *
32   * @version $Id: MutableDynaClass.java 1747095 2016-06-07 00:27:52Z ggregory $
33   */
34  
35  public interface MutableDynaClass extends DynaClass {
36  
37  
38      /**
39       * Add a new dynamic property with no restrictions on data type,
40       * readability, or writeability.
41       *
42       * @param name Name of the new dynamic property
43       *
44       * @throws IllegalArgumentException if name is null
45       * @throws IllegalStateException if this DynaClass is currently
46       *  restricted, so no new properties can be added
47       */
48      public void add(String name);
49  
50  
51      /**
52       * Add a new dynamic property with the specified data type, but with
53       * no restrictions on readability or writeability.
54       *
55       * @param name Name of the new dynamic property
56       * @param type Data type of the new dynamic property (null for no
57       *  restrictions)
58       *
59       * @throws IllegalArgumentException if name is null
60       * @throws IllegalStateException if this DynaClass is currently
61       *  restricted, so no new properties can be added
62       */
63      public void add(String name, Class<?> type);
64  
65  
66      /**
67       * Add a new dynamic property with the specified data type, readability,
68       * and writeability.
69       *
70       * @param name Name of the new dynamic property
71       * @param type Data type of the new dynamic property (null for no
72       *  restrictions)
73       * @param readable Set to <code>true</code> if this property value
74       *  should be readable
75       * @param writeable Set to <code>true</code> if this property value
76       *  should be writeable
77       *
78       * @throws IllegalArgumentException if name is null
79       * @throws IllegalStateException if this DynaClass is currently
80       *  restricted, so no new properties can be added
81       */
82      public void add(String name, Class<?> type, boolean readable,
83                      boolean writeable);
84  
85  
86      /**
87       * Is this DynaClass currently restricted, if so, no changes to the
88       * existing registration of property names, data types, readability, or
89       * writeability are allowed.
90       *
91       * @return <code>true</code> if this Mutable {@link DynaClass} is restricted,
92       * otherwise <code>false</code>
93       */
94      public boolean isRestricted();
95  
96  
97      /**
98       * Remove the specified dynamic property, and any associated data type,
99       * readability, and writeability, from this dynamic class.
100      * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
101      * corresponding property values to be removed from DynaBean instances
102      * associated with this DynaClass.
103      *
104      * @param name Name of the dynamic property to remove
105      *
106      * @throws IllegalArgumentException if name is null
107      * @throws IllegalStateException if this DynaClass is currently
108      *  restricted, so no properties can be removed
109      */
110     public void remove(String name);
111 
112 
113     /**
114      * Set the restricted state of this DynaClass to the specified value.
115      *
116      * @param restricted The new restricted state
117      */
118     public void setRestricted(boolean restricted);
119 
120 
121 }