< prev index next >

src/java.base/share/classes/java/lang/reflect/Field.java

Print this page




1111 
1112     // Returns FieldAccessor for this Field object, not looking up
1113     // the chain to the root
1114     private FieldAccessor getFieldAccessor(boolean overrideFinalCheck) {
1115         return (overrideFinalCheck)? overrideFieldAccessor : fieldAccessor;
1116     }
1117 
1118     // Sets the FieldAccessor for this Field object and
1119     // (recursively) its root
1120     private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
1121         if (overrideFinalCheck)
1122             overrideFieldAccessor = accessor;
1123         else
1124             fieldAccessor = accessor;
1125         // Propagate up
1126         if (root != null) {
1127             root.setFieldAccessor(accessor, overrideFinalCheck);
1128         }
1129     }
1130 





1131     /**
1132      * @throws NullPointerException {@inheritDoc}
1133      * @since 1.5
1134      */
1135     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
1136         Objects.requireNonNull(annotationClass);
1137         return annotationClass.cast(declaredAnnotations().get(annotationClass));
1138     }
1139 
1140     /**
1141      * {@inheritDoc}
1142      * @throws NullPointerException {@inheritDoc}
1143      * @since 1.8
1144      */
1145     @Override
1146     public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
1147         Objects.requireNonNull(annotationClass);
1148 
1149         return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
1150     }




1111 
1112     // Returns FieldAccessor for this Field object, not looking up
1113     // the chain to the root
1114     private FieldAccessor getFieldAccessor(boolean overrideFinalCheck) {
1115         return (overrideFinalCheck)? overrideFieldAccessor : fieldAccessor;
1116     }
1117 
1118     // Sets the FieldAccessor for this Field object and
1119     // (recursively) its root
1120     private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
1121         if (overrideFinalCheck)
1122             overrideFieldAccessor = accessor;
1123         else
1124             fieldAccessor = accessor;
1125         // Propagate up
1126         if (root != null) {
1127             root.setFieldAccessor(accessor, overrideFinalCheck);
1128         }
1129     }
1130 
1131     @Override
1132     Field getRoot() {
1133         return root;
1134     }
1135 
1136     /**
1137      * @throws NullPointerException {@inheritDoc}
1138      * @since 1.5
1139      */
1140     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
1141         Objects.requireNonNull(annotationClass);
1142         return annotationClass.cast(declaredAnnotations().get(annotationClass));
1143     }
1144 
1145     /**
1146      * {@inheritDoc}
1147      * @throws NullPointerException {@inheritDoc}
1148      * @since 1.8
1149      */
1150     @Override
1151     public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
1152         Objects.requireNonNull(annotationClass);
1153 
1154         return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
1155     }


< prev index next >