private static Set<String> writeMethod(TreeLogger logger,
            GeneratorContext context, JMethod method, SourceWriter writer)
            throws UnableToCompleteException {

        if (method.getParameters().length != 0) {
            logger.log(Type.ERROR, "Only supporting methods with no arguments");
            throw new UnableToCompleteException();
        }

        JType returnType = method.getReturnType();
        TypeHandler<Object> typeHandler = (TypeHandler<Object>) typeHandlers
                .get(returnType.getQualifiedSourceName());
        if (typeHandler == null) {
            logger.log(Type.ERROR, returnType.getQualifiedSourceName()
                    + " is not supported");
            throw new UnableToCompleteException();
        }

        final Set<String> usedSelectionProperties;
        Object returnValue;
        if (method.isAbstract()) {
            String propertyName = getPropertyName(method);
            String selectionPropertyValue = getStaticSelectionPropertyValue(
                    logger, context, propertyName);
            List<String> configurationPropertyValues = getStaticConfigurationPropertyValues(
                    context, propertyName);
            if (selectionPropertyValue == null
                    && configurationPropertyValues == null) {
                logger.log(Type.ERROR, "Property " + propertyName
                        + " not found");
                throw new UnableToCompleteException();
            }

            if (selectionPropertyValue != null) {
                returnValue = typeHandler.getStaticReturnValue(logger,
                        Collections.singletonList(selectionPropertyValue),
                        method);
                usedSelectionProperties = Collections.singleton(propertyName);
            } else {
                returnValue = typeHandler.getStaticReturnValue(logger,
                        configurationPropertyValues, method);
                usedSelectionProperties = null;
            }
        } else {
            usedSelectionProperties = new HashSet<String>();
            returnValue = getDynamicPropertyValue(
                    logger.branch(Type.DEBUG, "Evaluating method"), context,
                    method, usedSelectionProperties);
        }

        writer.println("%s {",
                method.getReadableDeclaration(false, false, false, false, true));
        writer.indent();

        writer.print("return ");
        typeHandler.writeValue(logger, writer, returnValue);
        writer.println(";");

        writer.outdent();
        writer.println("}");
        writer.println();

        return usedSelectionProperties;
    }