public Function build(Class<?> cls) {
        EdmFunction edmFunction = cls.getAnnotation(EdmFunction.class);
        EdmReturnType edmReturnType = cls.getAnnotation(EdmReturnType.class);
        if (edmReturnType == null) {
            throw new IllegalArgumentException(
                    "The class must have EdmReturnType: " + cls.getName());
        }
        Set<Parameter> parameters = new HashSet<>();
        for (Field field : cls.getDeclaredFields()) {
            EdmParameter parameterAnnotation = field.getAnnotation(EdmParameter.class);
            if (parameterAnnotation != null) {
                String parameterName = isNullOrEmpty(parameterAnnotation.name())
                        ? field.getName() : parameterAnnotation.name();
                String parameterType = isNullOrEmpty(parameterAnnotation.type())
                        ? field.getType().getSimpleName() : parameterAnnotation.type();
                parameters.add(new ParameterImpl.Builder()
                        .setMaxLength(parameterAnnotation.maxLength())
                        .setName(parameterName)
                        .setNullable(parameterAnnotation.nullable())
                        .setPrecision(parameterAnnotation.precision())
                        .setScale(parameterAnnotation.scale())
                        .setSRID(parameterAnnotation.srid())
                        .setType(parameterType)
                        .setUnicode(parameterAnnotation.unicode())
                        .setJavaField(field)
                        .build());
            }
        }

        return new FunctionImpl.Builder()
                .setBound(edmFunction.isBound())
                .setComposable(edmFunction.isComposable())
                .setEntitySetPath(edmFunction.entitySetPath())
                .setName(edmFunction.name())
                .setParameters(parameters)
                .setReturnType(edmReturnType.type())
                .setNamespace(edmFunction.namespace())
                .setJavaClass(cls)
                .build();
    }
public Function build ( Class < ? > cls ) { EdmFunction edmFunction = cls . getAnnotation ( EdmFunction . class ) ; EdmReturnType edmReturnType = cls . getAnnotation ( EdmReturnType . class ) ; if ( edmReturnType == null ) { throw new IllegalArgumentException ( "The class must have EdmReturnType: " + cls . getName ( ) ) ; } Set < Parameter > parameters = new HashSet < > ( ) ; for ( Field field : cls . getDeclaredFields ( ) ) { EdmParameter parameterAnnotation = field . getAnnotation ( EdmParameter . class ) ; if ( parameterAnnotation != null ) { String parameterName = isNullOrEmpty ( parameterAnnotation . name ( ) ) ? field . getName ( ) : parameterAnnotation . name ( ) ; String parameterType = isNullOrEmpty ( parameterAnnotation . type ( ) ) ? field . getType ( ) . getSimpleName ( ) : parameterAnnotation . type ( ) ; parameters . add ( new ParameterImpl . Builder ( ) . setMaxLength ( parameterAnnotation . maxLength ( ) ) . setName ( parameterName ) . setNullable ( parameterAnnotation . nullable ( ) ) . setPrecision ( parameterAnnotation . precision ( ) ) . setScale ( parameterAnnotation . scale ( ) ) . setSRID ( parameterAnnotation . srid ( ) ) . setType ( parameterType ) . setUnicode ( parameterAnnotation . unicode ( ) ) . setJavaField ( field ) . build ( ) ) ; } } return new FunctionImpl . Builder ( ) . setBound ( edmFunction . isBound ( ) ) . setComposable ( edmFunction . isComposable ( ) ) . setEntitySetPath ( edmFunction . entitySetPath ( ) ) . setName ( edmFunction . name ( ) ) . setParameters ( parameters ) . setReturnType ( edmReturnType . type ( ) ) . setNamespace ( edmFunction . namespace ( ) ) . setJavaClass ( cls ) . build ( ) ; }
Method to build Function implementation with parameters by class.
@param cls   function class
@return      built function