Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[#650] Code cleanup

  • Loading branch information...
commit 98505615f18b3e4a6c75e9a0147497138620a0a9 1 parent 26e89a1
Erwan Loisant erwan authored

Showing 1 changed file with 7 additions and 17 deletions. Show diff stats Hide diff stats

  1. +7 17 framework/src/play/data/binding/BeanWrapper.java
24 framework/src/play/data/binding/BeanWrapper.java
@@ -33,7 +33,7 @@
33 33
34 34 public static BeanWrapper forClass(Class<?> forClass) {
35 35 BeanWrapper beanWrapper = new JavaBeanWrapper(forClass);
36   - for (Class<?> intf : forClass.getInterfaces()) {
  36 + for (Class<?> intf: forClass.getInterfaces()) {
37 37 if ("scala.ScalaObject".equals(intf.getName())) {
38 38 beanWrapper = new ScalaBeanWrapper(forClass);
39 39 break;
@@ -154,20 +154,16 @@ private void registerSetters(Class<?> clazz) {
154 154 abstract String getPropertyName(Method method);
155 155
156 156 private static class JavaBeanWrapper extends BeanWrapper {
157   -
158 157 JavaBeanWrapper(Class<?> forClass) {
159 158 super(forClass);
160 159 }
161   -
162   - String getPropertyName(Method method) {
  160 + @Override String getPropertyName(Method method) {
163 161 return method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4);
164 162 }
165   -
166   - boolean isSetter(Method method) {
  163 + @Override boolean isSetter(Method method) {
167 164 return (!method.isAnnotationPresent(PlayPropertyAccessor.class) && method.getName().startsWith("set") && method.getName().length() > 3 && method.getParameterTypes().length == 1 && (method.getModifiers() & notaccessibleMethod) == 0);
168 165 }
169   -
170   - Collection<Field> getFields(Class<?> forClass) {
  166 + @Override Collection<Field> getFields(Class<?> forClass) {
171 167 final Collection<Field> fields = new ArrayList<Field>();
172 168 for (Field field : forClass.getFields()) {
173 169 if ((field.getModifiers() & notwritableField) != 0) {
@@ -183,20 +179,18 @@ boolean isSetter(Method method) {
183 179 ScalaBeanWrapper(Class<?> forClass) {
184 180 super(forClass);
185 181 }
186   - String getPropertyName(Method method) {
  182 + @Override String getPropertyName(Method method) {
187 183 return method.getName().substring(0, method.getName().length() - 4);
188 184 }
189   - boolean isSetter(Method method) {
  185 + @Override boolean isSetter(Method method) {
190 186 return (!method.isAnnotationPresent(PlayPropertyAccessor.class) && method.getName().endsWith("_$eq") && method.getParameterTypes().length == 1 && (method.getModifiers() & notaccessibleMethod) == 0);
191 187 }
192   -
193   - Collection<Field> getFields(Class<?> forClass) {
  188 + @Override Collection<Field> getFields(Class<?> forClass) {
194 189 return Arrays.asList(forClass.getDeclaredFields());
195 190 }
196 191 }
197 192
198 193 public static class Property {
199   -
200 194 private Annotation[] annotations;
201 195 private Method setter;
202 196 private Field field;
@@ -241,17 +235,13 @@ public void setValue(Object instance, Object value) {
241 235 if (Logger.isTraceEnabled()) {
242 236 Logger.trace("invoke setter %s on %s with value %s", setter, instance, value);
243 237 }
244   -
245 238 setter.invoke(instance, value);
246   - return;
247 239 } else {
248 240 if (Logger.isTraceEnabled()) {
249 241 Logger.trace("field.set(%s, %s)", instance, value);
250 242 }
251   -
252 243 field.set(instance, value);
253 244 }
254   -
255 245 } catch (Exception ex) {
256 246 Logger.warn(ex, "ERROR in BeanWrapper when setting property %s value is %s (%s)", name, value, value == null ? null : value.getClass());
257 247 throw new UnexpectedException(ex);

0 comments on commit 9850561

Please sign in to comment.
Something went wrong with that request. Please try again.