Class AOptionsFiller<TOptionsClass>

java.lang.Object
provided.owlMaps.cefUtils.impl.AOptionsFiller<TOptionsClass>
Type Parameters:
TOptionsClass - The class associated with this options processor
All Implemented Interfaces:
IOptionsFiller

public abstract class AOptionsFiller<TOptionsClass>
extends java.lang.Object
implements IOptionsFiller
FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS CLASS OR ANY SUBCLASS OF IT! An abstract IOptionsFiller that provides the basic functionality of an options filler. Subclasses need only to add component-specific options processors.
Author:
swong
  • Field Summary

    Fields
    Modifier and Type Field Description
    private ICefUtils cefUtils
    The map-dependent Javascript utilities object.
    private com.google.gson.Gson gson
    The Gson processing object.
    java.util.Map<provided.mixedData.MixedDataKey<?>,​IProcessOption<?>> optionFnMap
    The mapping from options key to options processor for the given options type
    private java.lang.Class<TOptionsClass> optionsClass
    The class associated with this options filler.
    private java.util.UUID optionsID
    The UUID corresponding to the type of options this options filler is built for.

    Fields inherited from interface provided.owlMaps.cefUtils.IOptionsFiller

    MAP_KEY
  • Constructor Summary

    Constructors
    Constructor Description
    AOptionsFiller​(ICefUtils cefUtils, java.lang.Class<TOptionsClass> optionsClass)
    Constructor for this abstract class
  • Method Summary

    Modifier and Type Method Description
    protected <T> void addToCefOptions​(provided.mixedData.MixedDataKey<T> key, T value, IProcessOption<?> defaultProcessOption, com.google.gson.stream.JsonWriter jsonWriter)
    Utility method to process a given Java options key-value with any installed handler in the internal optionFnMap or to use the IProcessOption.DEFAULT processing if no handler is installed.
    protected IProcessOption<ICefObject> makeDefaultMapOptionProcess()
    Utility method to make the default Map option processor
    com.google.gson.TypeAdapterFactory makeTypeAdapterFactory()
    *** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD! ***
    Factory method to make the TypeAdapterFactory for use by GSON to process a dictionary of a particular type of options.
    protected void processEntries​(provided.mixedData.IMixedDataDictionary optionsDict, com.google.gson.stream.JsonWriter jsonWriter)
    Process the associated entries in the given optionsDict
    protected <T> void put​(provided.mixedData.MixedDataKey<T> key, IProcessOption<T> value)
    Put the given options processor into the options processor map associated with the given options key.
    protected <T> java.lang.String toJson​(T value)
    Utility method to convert a value to a JSON string where the proper processing can be deduced from the object itself.
    protected <T> java.lang.String toJson​(T value, java.lang.Class<?> optionClass)
    Utility method to convert a value to a JSON string where the proper processing is explictly determined by the given Class object.

    Methods inherited from class java.lang.Object

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

    • cefUtils

      private ICefUtils cefUtils
      The map-dependent Javascript utilities object.
    • optionFnMap

      public java.util.Map<provided.mixedData.MixedDataKey<?>,​IProcessOption<?>> optionFnMap
      The mapping from options key to options processor for the given options type
    • optionsID

      private java.util.UUID optionsID
      The UUID corresponding to the type of options this options filler is built for. Each options type will have a unique ID value.
    • optionsClass

      private java.lang.Class<TOptionsClass> optionsClass
      The class associated with this options filler.
    • gson

      private com.google.gson.Gson gson
      The Gson processing object. Not available until after the TypeAdapterFactory has been accessed and its create() method is called.
  • Constructor Details

    • AOptionsFiller

      public AOptionsFiller​(ICefUtils cefUtils, java.lang.Class<TOptionsClass> optionsClass)
      Constructor for this abstract class
      Parameters:
      cefUtils - CEF utilities library
      optionsClass - The Class of associated with this options filler. MUST HAVE AN OPTIONS_ID STATIC FIELD!!
  • Method Details

    • toJson

      protected <T> java.lang.String toJson​(T value, java.lang.Class<?> optionClass)
      Utility method to convert a value to a JSON string where the proper processing is explictly determined by the given Class object. Use this method for anonymous inner class objects.
      Type Parameters:
      T - The type of the value to convert
      Parameters:
      value - The value to convert
      optionClass - The Class which determines how the value will be processed.
      Returns:
      A JSON string
    • toJson

      protected <T> java.lang.String toJson​(T value)
      Utility method to convert a value to a JSON string where the proper processing can be deduced from the object itself. WILL NOT WORK FOR ANONYMOUS INNER CLASS INSTANCES!! This method simply delegates to the underlying Gson object.
      Type Parameters:
      T - The type of the value to convert
      Parameters:
      value - The value to convert
      Returns:
      A JSON string
    • put

      protected <T> void put​(provided.mixedData.MixedDataKey<T> key, IProcessOption<T> value)
      Put the given options processor into the options processor map associated with the given options key.
      Type Parameters:
      T - The type of options value that will be processed by the given options processor
      Parameters:
      key - The options type to be processed
      value - The option processor to use for the given option type
    • makeTypeAdapterFactory

      public com.google.gson.TypeAdapterFactory makeTypeAdapterFactory()
      Description copied from interface: IOptionsFiller
      *** FOR INTERNAL USE ONLY!! DEVELOPER CODE SHOULD NEVER USE THIS METHOD! ***
      Factory method to make the TypeAdapterFactory for use by GSON to process a dictionary of a particular type of options.
      Specified by:
      makeTypeAdapterFactory in interface IOptionsFiller
      Returns:
      A TypeAdapterFactory instance
    • makeDefaultMapOptionProcess

      protected IProcessOption<ICefObject> makeDefaultMapOptionProcess()
      Utility method to make the default Map option processor
      Returns:
      A processor for a map option value
    • addToCefOptions

      protected <T> void addToCefOptions​(provided.mixedData.MixedDataKey<T> key, T value, IProcessOption<?> defaultProcessOption, com.google.gson.stream.JsonWriter jsonWriter)
      Utility method to process a given Java options key-value with any installed handler in the internal optionFnMap or to use the IProcessOption.DEFAULT processing if no handler is installed. This method is necessary in order to insure that the type specified the key is the same as the type that is retrieved from the optionsDict dictionary.
      Type Parameters:
      T - The type of the options value
      Parameters:
      key - The key to the options value
      value - A dictionary of options values
      defaultProcessOption - The processor to use if there is no override defined in optionFnMap
      jsonWriter - The GSON JSON writer to output the processed values
    • processEntries

      protected void processEntries​(provided.mixedData.IMixedDataDictionary optionsDict, com.google.gson.stream.JsonWriter jsonWriter)
      Process the associated entries in the given optionsDict
      Parameters:
      optionsDict - The dictionary of options
      jsonWriter - The GSON JSON writer to output the processed values