private boolean isStaticFieldProperty(PropertyAdapter adapter) { return adapter.isField() && Modifier.isStatic(adapter.getField().getModifiers()); } }
private void implementGetter(PropertyAdapter adapter) { if (adapter.getReadMethod() != null) { implementGetter(adapter.getReadMethod()); return; } if (adapter.getField() != null) { implementGetter(adapter.getField()); return; } implementNoOpMethod(ConduitMethods.GET, "Expression '%s' for class %s is write-only.", expression, rootType.getName()); }
private void implementSetter(PropertyAdapter adapter) { if (adapter.getWriteMethod() != null) { implementSetter(adapter.getWriteMethod()); return; } if (adapter.getField() != null && adapter.isUpdate()) { implementSetter(adapter.getField()); return; } implementNoOpMethod(ConduitMethods.SET, "Expression '%s' for class %s is read-only.", expression, rootType.getName()); }
private Type getGenericType(PropertyAdapter adapter) { Type genericType = null; if (adapter.getField() != null) { genericType = adapter.getField().getGenericType(); } else if (adapter.getReadMethod() != null) { genericType = adapter.getReadMethod().getGenericReturnType(); } else if (adapter.getWriteMethod() != null) { genericType = adapter.getWriteMethod().getGenericParameterTypes()[0]; } else { throw new RuntimeException("Could not find accessor for property " + adapter.getName()); } return genericType == null ? adapter.getType() : genericType; }
private Term buildPropertyAccessTerm(Type activeType, Tree termNode) { String propertyName = termNode.getText(); PropertyAdapter adapter = findPropertyAdapter(activeType, propertyName); // Prefer the accessor over the field if (adapter.getReadMethod() != null) { return buildGetterMethodAccessTerm(activeType, propertyName, adapter.getReadMethod()); } if (adapter.getField() != null) { return buildPublicFieldAccessTerm(activeType, propertyName, adapter.getField()); } throw new RuntimeException(String.format( "Property '%s' of class %s is not readable (it has no read accessor method).", adapter.getName(), adapter.getBeanType().getName())); }