All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gsonfire.postprocessors.methodinvoker.MappedMethodInspector Maven / Gradle / Ivy

Go to download

A java library that adds some very useful features to Gson, like Date serializing to unix timestamp or RFC3339, method (getter) serialization, pre and post processors and many more. Check out the documentation to learn how to use it!

There is a newer version: 1.9.0
Show newest version
package io.gsonfire.postprocessors.methodinvoker;

import io.gsonfire.annotations.ExposeMethodResult;
import io.gsonfire.util.reflection.AnnotationInspector;

import java.lang.reflect.Method;

/**
 * Created by julio on 7/25/15.
 */
final class MappedMethodInspector extends AnnotationInspector {

    @Override
    protected Method[] getDeclaredMembers(Class clazz) {
        return clazz.getDeclaredMethods();
    }

    @Override
    protected MappedMethod map(Method member) {
        if (member.getParameterTypes().length > 0) {
            throw new IllegalArgumentException("The methods annotated with ExposeMethodResult should have no arguments");
        }

        ExposeMethodResult exposeMethodResult = member.getAnnotation(ExposeMethodResult.class);

        MappedMethod mm = new MappedMethod(member, exposeMethodResult.value(), exposeMethodResult.conflictResolution());
        return mm;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy