Class MethodParsers

java.lang.Object
com.iohao.net.framework.core.flow.parser.MethodParsers

public final class MethodParsers extends Object
Registry of MethodParser implementations, mapping parameter types to their parsers.

Provides lookup, registration, and default-fallback for action method parameter/return type parsers. Built-in parsers handle primitive types (int, long, boolean, String) and their protocol wrapper counterparts.

Author:
渔民小镇
date:
2022-06-26
  • Constructor Details

    • MethodParsers

      public MethodParsers()
  • Method Details

    • clear

      public void clear()
      Clear all registered parsers and parameter suppliers.
    • mappingParamSupplier

      public void mappingParamSupplier(Class<?> paramClass, Supplier<?> supplier)
      Register a parameter supplier for the given class, used to create default instances when data is null.
      Parameters:
      paramClass - the parameter class
      supplier - the supplier to create default instances
    • getMethodParser

      public MethodParser getMethodParser(ActualParameter actionMethodReturn)
      Get the method parser for the given action method return or parameter metadata.
      Parameters:
      actionMethodReturn - the return or parameter type metadata
      Returns:
      the matching parser, or the default parser if no specific one is registered
    • keySet

      public Set<Class<?>> keySet()
    • getMethodParser

      public MethodParser getMethodParser(Class<?> paramClazz)
      Get the method parser for the given parameter class.
      Parameters:
      paramClazz - the parameter class
      Returns:
      the matching parser, or the default parser if no specific one is registered
    • containsKey

      public boolean containsKey(Class<?> clazz)
      Check whether a parser is registered for the given class.
      Parameters:
      clazz - the class to check
      Returns:
      true if a parser is registered for this class
    • mapping

      public void mapping(Class<?> paramClass, MethodParser methodParamParser)
      Register a method parser for the given parameter class.
      Parameters:
      paramClass - the parameter class
      methodParamParser - the parser to handle this class