1 package org.apache.commons.beanutils2;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static java.lang.String.format;
23
24 import java.beans.IntrospectionException;
25 import java.util.Map;
26
27 final class NullBeanAccessor<B>
28 implements BeanAccessor<B>
29 {
30
31 private final String errorMessage;
32
33 public NullBeanAccessor( String beanTypeName, String methodName )
34 {
35 errorMessage = format( "%s.%s returned null!", beanTypeName, methodName );
36 }
37
38
39
40
41 public BeanAccessor<?> get( String propertyName )
42 {
43 throw new NullPointerException( errorMessage );
44 }
45
46
47
48
49 public IndexedPropertyGetterAccessor<?> getIndexed( String propertyName )
50 {
51 throw new NullPointerException( errorMessage );
52 }
53
54
55
56
57 public MappedPropertyGetterAccessor getMapped( String propertyName )
58 {
59 throw new NullPointerException( errorMessage );
60 }
61
62
63
64
65 public B get()
66 {
67 return null;
68 }
69
70
71
72
73 public <V> V cast()
74 {
75 return null;
76 }
77
78
79
80
81 public BeanPropertySetter<B> set( String propertyName )
82 {
83 throw new NullPointerException( errorMessage );
84 }
85
86
87
88
89 public IndexedPropertySetterAccessor<B> setIndexed( String propertyName )
90 {
91 throw new NullPointerException( errorMessage );
92 }
93
94
95
96
97 public MappedPropertySetterAccessor<B> setMapped( String propertyName )
98 {
99 throw new NullPointerException( errorMessage );
100 }
101
102
103
104
105 public boolean isReadable( String propertyName )
106 throws IntrospectionException
107 {
108 throw new NullPointerException( errorMessage );
109 }
110
111
112
113
114 public boolean isWritable( String propertyName )
115 throws IntrospectionException
116 {
117 throw new NullPointerException( errorMessage );
118 }
119
120
121
122
123 public B cloneBean()
124 {
125 return null;
126 }
127
128
129
130
131 public <T extends B> void copyPropertiesTo( T target )
132 {
133 throw new NullPointerException( errorMessage );
134 }
135
136
137
138
139 public Map<String, Object> describe()
140 {
141 throw new NullPointerException( errorMessage );
142 }
143
144
145
146
147 public void populate( Map<String, Object> properties )
148 {
149 throw new NullPointerException( errorMessage );
150 }
151
152
153
154
155 public ArgumentsAccessor invoke( String methodName )
156 {
157 throw new NullPointerException( errorMessage );
158 }
159
160
161
162
163 public ArgumentsAccessor invokeExact( String methodName )
164 {
165 throw new NullPointerException( errorMessage );
166 }
167
168 }