Class VerbMethod

java.lang.Object
mg.emberframework.core.data.VerbMethod

public class VerbMethod extends Object
Represents a method associated with an HTTP verb.

This class pairs a Method with its corresponding HTTP verb (e.g., GET, POST) and provides utilities to validate requests and check for REST API status.

Since:
1.0.0
Version:
1.0.0
Author:
Sandratra NIAINA
  • Constructor Details

    • VerbMethod

      public VerbMethod(Method method, String verb)
      Constructs a verb-method pair.
      Parameters:
      method - the method
      verb - the associated HTTP verb
  • Method Details

    • isRequestValid

      public boolean isRequestValid(jakarta.servlet.http.HttpServletRequest request)
      Checks if the HTTP request matches the method's verb.
      Parameters:
      request - the HTTP request
      Returns:
      true if the request method matches the verb, false otherwise
    • isRestAPI

      public boolean isRestAPI()
      Checks if the method is annotated as a REST API endpoint.
      Returns:
      true if annotated with @RestApi, false otherwise
    • getMethod

      public Method getMethod()
      Gets the method.
      Returns:
      the method
    • setMethod

      public void setMethod(Method method)
      Sets the method.
      Parameters:
      method - the method to set
    • getVerb

      public String getVerb()
      Gets the HTTP verb.
      Returns:
      the verb
    • setVerb

      public void setVerb(String verb)
      Sets the HTTP verb.
      Parameters:
      verb - the verb to set
    • equals

      public boolean equals(Object obj)
      Compares this object to another for equality based on the verb.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if the verbs match (case-insensitive), false otherwise
    • hashCode

      public int hashCode()
      Computes the hash code based on the verb.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code