public List<String> getPossibleGetterNames(final FieldDeclaration it) { final ArrayList<String> names = CollectionLiterals.<String>newArrayList(); if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) { String _simpleName = it.getSimpleName(); names.add(_simpleName); } List<String> _xifexpression = null; boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType())); if (_isBooleanType) { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get")); } else { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get")); } final Function1<String, String> _function = (String prefix) -> { String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName()); return (prefix + _firstUpper); }; names.addAll(ListExtensions.<String, String>map(_xifexpression, _function)); return names; }
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); }
public boolean hasSetter(final FieldDeclaration it) { MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(this.getSetterName(it), this.orObject(it.getType())); return (_findDeclaredMethod != null); }