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

com.github.hammelion.matchers.method.MethodNameRule Maven / Gradle / Ivy

Go to download

Jraml helps you build your java implementation of REST API, based on specification, described by raml file.

There is a newer version: 0.3
Show newest version
package com.github.hammelion.matchers.method;

import java.lang.reflect.Method;

import javax.inject.Named;
import javax.ws.rs.Path;

/**
 * TODO JavaDoc in org.jraml.matchers.method
 */
@Named
class MethodNameRule {

    public boolean matches(Method method, String name) {
        return hasMatchingPathAnnotation(method, name) || nameStartsWithAction(method, name);
    }

    private boolean hasMatchingPathAnnotation(Method method, String name) {
        final Path path = method.getAnnotation(Path.class);
        if (path != null) {
            return path.value().equalsIgnoreCase(name);
        }
        return false;
    }

    private boolean nameStartsWithAction(Method method, String name) {
        return method.getName().startsWith(name);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy