1 /* 2 * Copyright 2004-2009 the Seasar Foundation and the Others. 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, 13 * either express or implied. See the License for the specific language 14 * governing permissions and limitations under the License. 15 */ 16 package org.seasar.cubby.spi.beans; 17 18 import java.lang.annotation.Annotation; 19 20 /** 21 * オブジェクトの属性を扱うためのインターフェイスです。 22 * 23 * @author baba 24 */ 25 public interface Attribute { 26 27 /** 28 * 属性名を返します。 29 * 30 * @return 属性名 31 */ 32 String getName(); 33 34 /** 35 * 属性の型を返します。 36 * 37 * @return 属性の型 38 */ 39 Class<?> getType(); 40 41 /** 42 * 属性の値が取得可能かどうかを返します。 43 * 44 * @return 属性の値が取得可能かどうか 45 */ 46 boolean isReadable(); 47 48 /** 49 * 属性の値が設定可能かどうかを返します。 50 * 51 * @return 属性の値が設定可能かどうか 52 */ 53 boolean isWritable(); 54 55 /** 56 * 属性の値を返します。 57 * 58 * @param target 59 * 値を取得するオブジェクト 60 * @return 属性の値 61 * @throws IllegalAttributeException 62 * 値の取得に失敗した場合。 63 */ 64 Object getValue(Object target); 65 66 /** 67 * 属性に値を設定します。 68 * 69 * @param target 70 * 値を設定するオブジェクト 71 * @param value 72 * 設定する値 73 * @throws IllegalAttributeException 74 * 値の設定に失敗した場合 75 */ 76 void setValue(Object target, Object value); 77 78 /** 79 * この属性がパラメタ化された型の場合、その情報を返します。 80 * <p> 81 * この属性がパラメタ化された型でない場合は<code>null</code>を返します。 82 * </p> 83 * 84 * @return この属性がパラメタ化された型の場合、その情報 85 */ 86 ParameterizedClassDesc getParameterizedClassDesc(); 87 88 /** 89 * 属性から指定されたアノテーションを取得します。 90 * 91 * @param <T> 92 * アノテーション 93 * @param annotationClass 94 * 取得するアノテーションの型 95 * @return アノテーション 96 */ 97 <T extends Annotation> T getAnnotation(Class<T> annotationClass); 98 99 /** 100 * 属性が指定されたアノテーションで修飾されているかを示します。 101 * 102 * @param annotationClass 103 * アノテーションの型 104 * @return 属性が指定されたアノテーションで修飾されている場合は <code>true</code>、そうでない場合は 105 * <code>false</code> 106 */ 107 boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); 108 109 }