001 // Copyright 2006, 2007, 2011 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.ioc.services; 016 017 import java.util.List; 018 019 /** 020 * Organizes all {@link org.apache.tapestry5.ioc.services.PropertyAdapter}s for a particular class. 021 * <p/> 022 * Only provides access to <em>simple</em> properties. Indexed properties are ignored. 023 * <p/> 024 * When accessing properties by name, the case of the name is ignored. 025 */ 026 public interface ClassPropertyAdapter 027 { 028 /** 029 * Returns the names of all properties, sorted into alphabetic order. This includes true properties 030 * (as defined in the JavaBeans specification), but also public fields. Starting in Tapestry 5.3, even public static fields are included. 031 */ 032 List<String> getPropertyNames(); 033 034 /** 035 * Returns the type of bean this adapter provides properties for. 036 */ 037 Class getBeanType(); 038 039 /** 040 * Returns the property adapter with the given name, or null if no such adapter exists. 041 * 042 * @param name of the property (case is ignored) 043 */ 044 PropertyAdapter getPropertyAdapter(String name); 045 046 /** 047 * Reads the value of a property. 048 * 049 * @param instance the object to read a value from 050 * @param propertyName the name of the property to read (case is ignored) 051 * @throws UnsupportedOperationException if the property is write only 052 * @throws IllegalArgumentException if property does not exist 053 */ 054 Object get(Object instance, String propertyName); 055 056 /** 057 * Updates the value of a property. 058 * 059 * @param instance the object to update 060 * @param propertyName the name of the property to update (case is ignored) 061 * @throws UnsupportedOperationException if the property is read only 062 * @throws IllegalArgumentException if property does not exist 063 */ 064 void set(Object instance, String propertyName, Object value); 065 }