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 * https://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 package org.apache.commons.beanutils2;
18
19 /**
20 * <p>
21 * A <strong>DynaClass</strong> is a simulation of the functionality of {@link Class} for classes implementing the {@code DynaBean} interface. DynaBean
22 * instances that share the same DynaClass all have the same set of available properties, along with any associated data types, read-only states, and write-only
23 * states.
24 * </p>
25 */
26 public interface DynaClass {
27
28 /**
29 * <p>
30 * Returns an array of {@code PropertyDescriptor} for the properties currently defined in this DynaClass. If no properties are defined, a zero-length array
31 * will be returned.
32 * </p>
33 *
34 * <p>
35 * <strong>FIXME</strong> - Should we really be implementing {@code getBeanInfo()} instead, which returns property descriptors and a bunch of other stuff?
36 * </p>
37 *
38 * @return the set of properties for this DynaClass
39 */
40 DynaProperty[] getDynaProperties();
41
42 /**
43 * Returns a property descriptor for the specified property, if it exists; otherwise, return {@code null}.
44 *
45 * @param name Name of the dynamic property for which a descriptor is requested
46 * @return The descriptor for the specified property
47 * @throws IllegalArgumentException if no property name is specified
48 */
49 DynaProperty getDynaProperty(String name);
50
51 /**
52 * Returns the name of this DynaClass (analogous to the {@code getName()} method of {@link Class}, which allows the same {@code DynaClass} implementation
53 * class to support different dynamic classes, with different sets of properties.
54 *
55 * @return the name of the DynaClass
56 */
57 String getName();
58
59 /**
60 * Instantiates and return a new DynaBean instance, associated with this DynaClass.
61 *
62 * @return A new {@code DynaBean} instance
63 * @throws IllegalAccessException if the Class or the appropriate constructor is not accessible
64 * @throws InstantiationException if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some
65 * other reason
66 */
67 DynaBean newInstance() throws IllegalAccessException, InstantiationException;
68
69 }