    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.beanutils2;
    018
    019/**
    020 * <p>
    021 * A <strong>DynaClass</strong> is a simulation of the functionality of {@link Class} for classes implementing the {@code DynaBean} interface. DynaBean
    022 * 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
    023 * states.
    024 * </p>
    025 */
    026public interface DynaClass {
    027
    028    /**
    029     * <p>
    030     * Returns an array of {@code PropertyDescriptor} for the properties currently defined in this DynaClass. If no properties are defined, a zero-length array
    031     * will be returned.
    032     * </p>
    033     *
    034     * <p>
    035     * <strong>FIXME</strong> - Should we really be implementing {@code getBeanInfo()} instead, which returns property descriptors and a bunch of other stuff?
    036     * </p>
    037     *
    038     * @return the set of properties for this DynaClass
    039     */
    040    DynaProperty[] getDynaProperties();
    041
    042    /**
    043     * Returns a property descriptor for the specified property, if it exists; otherwise, return {@code null}.
    044     *
    045     * @param name Name of the dynamic property for which a descriptor is requested
    046     * @return The descriptor for the specified property
    047     * @throws IllegalArgumentException if no property name is specified
    048     */
    049    DynaProperty getDynaProperty(String name);
    050
    051    /**
    052     * Returns the name of this DynaClass (analogous to the {@code getName()} method of {@link Class}, which allows the same {@code DynaClass} implementation
    053     * class to support different dynamic classes, with different sets of properties.
    054     *
    055     * @return the name of the DynaClass
    056     */
    057    String getName();
    058
    059    /**
    060     * Instantiates and return a new DynaBean instance, associated with this DynaClass.
    061     *
    062     * @return A new {@code DynaBean} instance
    063     * @throws IllegalAccessException if the Class or the appropriate constructor is not accessible
    064     * @throws InstantiationException if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some
    065     *                                other reason
    066     */
    067    DynaBean newInstance() throws IllegalAccessException, InstantiationException;
    068
    069}