Class Reflective


  • public final class Reflective
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Set<java.lang.String> KEYWORDS  
      static java.lang.String MAIN  
      static java.lang.Object NO_MATCH  
    • Constructor Summary

      Constructors 
      Constructor Description
      Reflective()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object coerce​(CommandSession session, java.lang.Class<?> type, java.lang.Object arg, int[] convert)
      converts given argument to specified type and increments convert[0] if any conversion was needed.
      static java.lang.Object invoke​(CommandSession session, java.lang.Object target, java.lang.String name, java.util.List<java.lang.Object> args)
      invokes the named method on the given target using the supplied args, which are converted if necessary.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_MATCH

        public static final java.lang.Object NO_MATCH
      • KEYWORDS

        public static final java.util.Set<java.lang.String> KEYWORDS
    • Constructor Detail

      • Reflective

        public Reflective()
    • Method Detail

      • invoke

        public static java.lang.Object invoke​(CommandSession session,
                                              java.lang.Object target,
                                              java.lang.String name,
                                              java.util.List<java.lang.Object> args)
                                       throws java.lang.Exception
        invokes the named method on the given target using the supplied args, which are converted if necessary.
        Returns:
        the result of the invoked method
        Throws:
        java.lang.Exception
      • coerce

        public static java.lang.Object coerce​(CommandSession session,
                                              java.lang.Class<?> type,
                                              java.lang.Object arg,
                                              int[] convert)
        converts given argument to specified type and increments convert[0] if any conversion was needed.
        Parameters:
        convert - convert[0] is incremented according to the conversion needed, to allow the "best" conversion to be determined.
        Returns:
        converted arg or NO_MATCH if no conversion possible.