private AccessorMethodWriter(Method method, Accessor accessor) { super(method); targetFieldName = accessor.value(); this.fieldRefName = "field$" + targetFieldName; String methodName = method.getName(); if (methodName.startsWith("get")) { if (method.getReturnType().equals(void.class)) { throw new IllegalArgumentException(method + " should have a non-void return type"); } if (method.getParameterCount() != 0) { throw new IllegalArgumentException(method + " should take no parameters"); } isSetter = false; } else if (methodName.startsWith("set")) { if (!method.getReturnType().equals(void.class)) { throw new IllegalArgumentException(method + " should have a void return type"); } if (method.getParameterCount() != 1) { throw new IllegalArgumentException(method + " should take a single parameter"); } isSetter = true; } else { throw new IllegalArgumentException( methodName + " doesn't appear to be a setter or a getter"); } }
private AccessorMethodWriter(Method method, Accessor accessor) { super(method); targetFieldName = accessor.value(); this.fieldRefName = "field$" + targetFieldName; String methodName = method.getName(); if (methodName.startsWith("get")) { if (method.getReturnType().equals(void.class)) { throw new IllegalArgumentException(method + " should have a non-void return type"); } if (method.getParameterCount() != 0) { throw new IllegalArgumentException(method + " should take no parameters"); } isSetter = false; } else if (methodName.startsWith("set")) { if (!method.getReturnType().equals(void.class)) { throw new IllegalArgumentException(method + " should have a void return type"); } if (method.getParameterCount() != 1) { throw new IllegalArgumentException(method + " should take a single parameter"); } isSetter = true; } else { throw new IllegalArgumentException( methodName + " doesn't appear to be a setter or a getter"); } }