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

com.carma.swagger.doclet.model.HttpMethod Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.carma.swagger.doclet.model;

import com.sun.javadoc.AnnotationDesc;
import com.sun.javadoc.MethodDoc;

import java.util.ArrayList;
import java.util.List;

public enum HttpMethod {
    GET("javax.ws.rs.GET"),
    PUT("javax.ws.rs.PUT"),
    POST("javax.ws.rs.POST"),
    DELETE("javax.ws.rs.DELETE");

    private final String canonicalClassname;

    private HttpMethod(String canonicalClassname) {
        this.canonicalClassname = canonicalClassname;
    }

    public static HttpMethod fromMethod(MethodDoc method) {
        List typeNames = new ArrayList();
        for (AnnotationDesc annotation : method.annotations()) {
            typeNames.add(annotation.annotationType().qualifiedTypeName());
        }
        HttpMethod found = null;
        for (HttpMethod value : HttpMethod.values()) {
            if (typeNames.contains(value.canonicalClassname)) {
                found = value;
                break;
            }
        }
        return found;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy