it.addAnnotation(context.newAnnotationReference(Override.class)); it.addAnnotation(context.newAnnotationReference(Pure.class)); final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); StringConcatenationClient _client = new StringConcatenationClient() { @Override
}; final Consumer<MutableFieldDeclaration> _function_1 = (MutableFieldDeclaration field) -> { final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); final AnnotationReference deprecated = field.findAnnotation(context.findTypeGlobally(Deprecated.class)); accessorsUtil.addGetter(field, Visibility.PUBLIC); AnnotationReference _findAnnotation = field.findAnnotation(context.newTypeReference(NonNull.class).getType()); final boolean hasNonNull = (_findAnnotation != null); MutableMethodDeclaration _findDeclaredMethod = impl.findDeclaredMethod(accessorsUtil.getGetterName(field)); final Procedure1<MutableMethodDeclaration> _function_2 = (MutableMethodDeclaration it) -> { it.setDocComment(field.getDocComment()); boolean _not = (!_isInferred); if (_not) { accessorsUtil.addSetter(field, Visibility.PUBLIC); final String setterName = accessorsUtil.getSetterName(field); MutableMethodDeclaration _findDeclaredMethod_1 = impl.findDeclaredMethod(setterName, field.getType()); final Procedure1<MutableMethodDeclaration> _function_3 = (MutableMethodDeclaration it) -> {
public AccessorType getSetterType(final FieldDeclaration it) { AnnotationReference _elvis = null; AnnotationReference _accessorsAnnotation = this.getAccessorsAnnotation(it); if (_accessorsAnnotation != null) { _elvis = _accessorsAnnotation; } else { AnnotationReference _accessorsAnnotation_1 = this.getAccessorsAnnotation(it.getDeclaringType()); _elvis = _accessorsAnnotation_1; } final AnnotationReference annotation = _elvis; if ((annotation != null)) { final Function1<EnumerationValueDeclaration, AccessorType> _function = (EnumerationValueDeclaration it_1) -> { return AccessorType.valueOf(it_1.getSimpleName()); }; final List<AccessorType> types = ListExtensions.<EnumerationValueDeclaration, AccessorType>map(((List<EnumerationValueDeclaration>)Conversions.doWrapArray(annotation.getEnumArrayValue("value"))), _function); AccessorType _elvis_1 = null; final Function1<AccessorType, Boolean> _function_1 = (AccessorType it_1) -> { return Boolean.valueOf(it_1.name().endsWith("SETTER")); }; AccessorType _findFirst = IterableExtensions.<AccessorType>findFirst(types, _function_1); if (_findFirst != null) { _elvis_1 = _findFirst; } else { _elvis_1 = AccessorType.NONE; } return _elvis_1; } return null; }
final DataProcessor.Util util = new DataProcessor.Util(context); @Extension final AccessorsProcessor.Util getterUtil = new AccessorsProcessor.Util(context); @Extension final EqualsHashCodeProcessor.Util ehUtil = new EqualsHashCodeProcessor.Util(context); boolean _shouldAddGetter = getterUtil.shouldAddGetter(it_1); if (_shouldAddGetter) { Visibility _elvis_2 = null; AccessorType _getterType = getterUtil.getGetterType(it_1); Visibility _visibility = null; if (_getterType!=null) { _visibility=getterUtil.toVisibility(_getterType); _elvis_2 = Visibility.PUBLIC; getterUtil.addGetter(it_1, _elvis_2);
it.addAnnotation(context.newAnnotationReference(Override.class)); it.addAnnotation(context.newAnnotationReference(Pure.class)); final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); StringConcatenationClient _client = new StringConcatenationClient() { @Override
}; final Consumer<MutableFieldDeclaration> _function_1 = (MutableFieldDeclaration field) -> { final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); final AnnotationReference deprecated = field.findAnnotation(context.findTypeGlobally(Deprecated.class)); accessorsUtil.addGetter(field, Visibility.PUBLIC); AnnotationReference _findAnnotation = field.findAnnotation(context.newTypeReference(NonNull.class).getType()); final boolean hasNonNull = (_findAnnotation != null); MutableMethodDeclaration _findDeclaredMethod = impl.findDeclaredMethod(accessorsUtil.getGetterName(field)); final Procedure1<MutableMethodDeclaration> _function_2 = (MutableMethodDeclaration it) -> { it.setDocComment(field.getDocComment()); boolean _not = (!_isInferred); if (_not) { accessorsUtil.addSetter(field, Visibility.PUBLIC); final String setterName = accessorsUtil.getSetterName(field); MutableMethodDeclaration _findDeclaredMethod_1 = impl.findDeclaredMethod(setterName, field.getType()); final Procedure1<MutableMethodDeclaration> _function_3 = (MutableMethodDeclaration it) -> {
final DataProcessor.Util util = new DataProcessor.Util(context); @Extension final AccessorsProcessor.Util getterUtil = new AccessorsProcessor.Util(context); @Extension final EqualsHashCodeProcessor.Util ehUtil = new EqualsHashCodeProcessor.Util(context); boolean _shouldAddGetter = getterUtil.shouldAddGetter(it_1); if (_shouldAddGetter) { getterUtil.addGetter(it_1, Visibility.PUBLIC);
public AccessorType getGetterType(final FieldDeclaration it) { AnnotationReference _elvis = null; AnnotationReference _accessorsAnnotation = this.getAccessorsAnnotation(it); if (_accessorsAnnotation != null) { _elvis = _accessorsAnnotation; } else { AnnotationReference _accessorsAnnotation_1 = this.getAccessorsAnnotation(it.getDeclaringType()); _elvis = _accessorsAnnotation_1; } final AnnotationReference annotation = _elvis; if ((annotation != null)) { final Function1<EnumerationValueDeclaration, AccessorType> _function = (EnumerationValueDeclaration it_1) -> { return AccessorType.valueOf(it_1.getSimpleName()); }; final List<AccessorType> types = ListExtensions.<EnumerationValueDeclaration, AccessorType>map(((List<EnumerationValueDeclaration>)Conversions.doWrapArray(annotation.getEnumArrayValue("value"))), _function); AccessorType _elvis_1 = null; final Function1<AccessorType, Boolean> _function_1 = (AccessorType it_1) -> { return Boolean.valueOf(it_1.name().endsWith("GETTER")); }; AccessorType _findFirst = IterableExtensions.<AccessorType>findFirst(types, _function_1); if (_findFirst != null) { _elvis_1 = _findFirst; } else { _elvis_1 = AccessorType.NONE; } return _elvis_1; } return null; }
public void addSetter(final MutableFieldDeclaration field, final Visibility visibility) { this.validateSetter(field); final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> { this.context.setPrimarySourceElement(it, this.context.getPrimarySourceElement(field)); it.setReturnType(this.context.getPrimitiveVoid()); final MutableParameterDeclaration param = it.addParameter(field.getSimpleName(), this.orObject(field.getType())); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { Object _fieldOwner = Util.this.fieldOwner(field); _builder.append(_fieldOwner); _builder.append("."); String _simpleName = field.getSimpleName(); _builder.append(_simpleName); _builder.append(" = "); String _simpleName_1 = param.getSimpleName(); _builder.append(_simpleName_1); _builder.append(";"); } }; it.setBody(_client); it.setStatic(field.isStatic()); it.setVisibility(visibility); }; field.getDeclaringType().addMethod(this.getSetterName(field), _function); }
public void addGetter(final MutableFieldDeclaration field, final Visibility visibility) { this.validateGetter(field); field.markAsRead(); final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> { this.context.setPrimarySourceElement(it, this.context.getPrimarySourceElement(field)); it.addAnnotation(this.context.newAnnotationReference(Pure.class)); it.setReturnType(this.orObject(field.getType())); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return "); Object _fieldOwner = Util.this.fieldOwner(field); _builder.append(_fieldOwner); _builder.append("."); String _simpleName = field.getSimpleName(); _builder.append(_simpleName); _builder.append(";"); } }; it.setBody(_client); it.setStatic(field.isStatic()); it.setVisibility(visibility); }; field.getDeclaringType().addMethod(this.getGetterName(field), _function); }
@Override public void doTransform(final MutableFieldDeclaration it, @Extension final TransformationContext context) { @Extension final AccessorsProcessor.Util util = new AccessorsProcessor.Util(context); boolean _hasGetter = util.hasGetter(it); boolean _not = (!_hasGetter); if (_not) { util.addGetter(it, Visibility.PUBLIC); } if (((!it.isFinal()) && (!util.hasSetter(it)))) { util.addSetter(it, Visibility.PUBLIC); } String _firstLower = StringExtensions.toFirstLower(it.getSimpleName()); String _plus = ("_" + _firstLower); it.setSimpleName(_plus); } }
public boolean shouldAddSetter(final FieldDeclaration it) { return (((!it.isFinal()) && (!this.hasSetter(it))) && (this.getSetterType(it) != AccessorType.NONE)); }
public String getGetterName(final FieldDeclaration it) { return IterableExtensions.<String>head(this.getPossibleGetterNames(it)); }
public boolean shouldAddGetter(final FieldDeclaration it) { return ((!this.hasGetter(it)) && (this.getGetterType(it) != AccessorType.NONE)); }
public boolean hasSetter(final FieldDeclaration it) { MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(this.getSetterName(it), this.orObject(it.getType())); return (_findDeclaredMethod != null); }
protected void _transform(final MutableFieldDeclaration it, @Extension final TransformationContext context) { @Extension final AccessorsProcessor.Util util = new AccessorsProcessor.Util(context); boolean _shouldAddGetter = util.shouldAddGetter(it); if (_shouldAddGetter) { util.addGetter(it, util.toVisibility(util.getGetterType(it))); } boolean _shouldAddSetter = util.shouldAddSetter(it); if (_shouldAddSetter) { util.addSetter(it, util.toVisibility(util.getSetterType(it))); } }
public boolean hasGetter(final FieldDeclaration it) { final Function1<String, Boolean> _function = (String name) -> { MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(name); return Boolean.valueOf((_findDeclaredMethod != null)); }; return IterableExtensions.<String>exists(this.getPossibleGetterNames(it), _function); }