Class Mapping

java.lang.Object
mg.emberframework.core.url.Mapping

public class Mapping extends Object
Represents a mapping of a URL to a set of HTTP verb-specific methods.

This class associates a controller class with a collection of VerbMethod instances, each corresponding to an HTTP verb (e.g., GET, POST), and ensures no duplicate verb mappings are added for the same URL.

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

    • Mapping

      public Mapping()
      Default constructor.
    • Mapping

      public Mapping(Class<?> clazz)
      Constructs a mapping with a specified controller class.
      Parameters:
      clazz - the controller class
  • Method Details

    • getSpecificVerbMethod

      public VerbMethod getSpecificVerbMethod(String verb) throws InvalidRequestException
      Retrieves the VerbMethod for a specific HTTP verb.
      Parameters:
      verb - the HTTP verb (e.g., "GET", "POST")
      Returns:
      the corresponding VerbMethod
      Throws:
      InvalidRequestException - if no method is found for the specified verb
    • addVerbMethod

      public void addVerbMethod(VerbMethod verbMethod) throws DuplicateUrlException
      Adds a VerbMethod to the mapping.
      Parameters:
      verbMethod - the verb-specific method to add
      Throws:
      DuplicateUrlException - if a method for the same verb already exists
    • getClazz

      public Class<?> getClazz()
      Gets the controller class associated with this mapping.
      Returns:
      the controller class
    • setClazz

      public void setClazz(Class<?> clazz)
      Sets the controller class associated with this mapping.
      Parameters:
      clazz - the controller class to set
    • getVerbMethods

      public Set<VerbMethod> getVerbMethods()
      Gets the set of verb-specific methods.
      Returns:
      the set of VerbMethod instances
    • setVerbMethods

      public void setVerbMethods(Set<VerbMethod> verbMethods)
      Sets the set of verb-specific methods.
      Parameters:
      verbMethods - the set of VerbMethod instances to set