Class Callback

  • All Implemented Interfaces:
    java.util.Map

    class Callback
    extends SampMap
    Map representing a client callback from the hub. It normally contains a callback method name and a list of parameters. An instance of this class can be used to correspond to one of the calls in the CallableClient interface.
    Since:
    2 Feb 2011
    Author:
    Mark Taylor
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String[] KNOWN_KEYS  
      static java.lang.String METHODNAME_KEY
      Key for the callback method name (a string).
      static java.lang.String PARAMS_KEY
      Key for the callback parameters (a list).
    • Constructor Summary

      Constructors 
      Constructor Description
      Callback()
      Constructs an empty callback.
      Callback​(java.lang.String methodName, java.util.List params)
      Constructs a callback given a method name and parameter list.
      Callback​(java.util.Map map)
      Constructs a callback based on an existing map.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Callback asCallback​(java.util.Map map)
      Returns a given map as a Callback object.
      void check()
      Checks that this object is ready for use with the SAMP toolkit.
      java.lang.String getMethodName()
      Returns the method name.
      java.util.List getParams()
      Returns the parameter list.
      void setMethodName​(java.lang.String methodName)
      Sets the method name.
      void setParams​(java.util.List params)
      Sets the parameter list.
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Field Detail

      • METHODNAME_KEY

        public static final java.lang.String METHODNAME_KEY
        Key for the callback method name (a string).
        See Also:
        Constant Field Values
      • PARAMS_KEY

        public static final java.lang.String PARAMS_KEY
        Key for the callback parameters (a list).
        See Also:
        Constant Field Values
      • KNOWN_KEYS

        private static final java.lang.String[] KNOWN_KEYS
    • Constructor Detail

      • Callback

        public Callback()
        Constructs an empty callback.
      • Callback

        public Callback​(java.util.Map map)
        Constructs a callback based on an existing map.
        Parameters:
        map - contents
      • Callback

        public Callback​(java.lang.String methodName,
                        java.util.List params)
        Constructs a callback given a method name and parameter list.
    • Method Detail

      • setMethodName

        public void setMethodName​(java.lang.String methodName)
        Sets the method name.
        Parameters:
        methodName - method name
      • getMethodName

        public java.lang.String getMethodName()
        Returns the method name.
        Returns:
        method name
      • setParams

        public void setParams​(java.util.List params)
        Sets the parameter list.
        Parameters:
        params - parameter list
      • getParams

        public java.util.List getParams()
        Returns the parameter list.
        Returns:
        parameter list
      • check

        public void check()
        Description copied from class: SampMap
        Checks that this object is ready for use with the SAMP toolkit. As well as calling SampUtils.checkMap(java.util.Map) (ensuring that all keys are Strings, and all values Strings, Lists or Maps), subclass-specific invariants may be checked. In the case that there's something wrong, an informative DataException will be thrown.
        Overrides:
        check in class SampMap
      • asCallback

        public static Callback asCallback​(java.util.Map map)
        Returns a given map as a Callback object.
        Parameters:
        map - map
        Returns:
        callback