Class SqlLibraryOperatorTableFactory


  • public class SqlLibraryOperatorTableFactory
    extends java.lang.Object
    Factory that creates operator tables that consist of functions and operators for particular named libraries. For example, the following code will return an operator table that contains operators for both Oracle and MySQL:
    SqlOperatorTable opTab =
         SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
             EnumSet.of(SqlLibrary.ORACLE, SqlLibrary.MYSQL))

    To define a new library, add a value to enum SqlLibrary.

    To add functions to a library, add the LibraryOperator annotation to fields that of type SqlOperator, and the library name to its LibraryOperator.libraries() field.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.common.cache.LoadingCache<com.google.common.collect.ImmutableSet<SqlLibrary>,​SqlOperatorTable> cache
      A cache that returns an operator table for a given library (or set of libraries).
      private com.google.common.collect.ImmutableList<java.lang.Class> classes
      List of classes to scan for operators.
      static SqlLibraryOperatorTableFactory INSTANCE
      The singleton instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private SqlOperatorTable create​(com.google.common.collect.ImmutableSet<SqlLibrary> librarySet)
      Creates an operator table that contains operators in the given set of libraries.
      SqlOperatorTable getOperatorTable​(java.lang.Iterable<SqlLibrary> librarySet)
      Returns a SQL operator table that contains operators in the given set of libraries.
      SqlOperatorTable getOperatorTable​(SqlLibrary... libraries)
      Returns a SQL operator table that contains operators in the given library or libraries.
      private boolean operatorIsInLibrary​(java.lang.String operatorName, java.lang.reflect.Field field, java.util.Set<SqlLibrary> seekLibrarySet)
      Returns whether an operator is in one or more of the given libraries.
      • Methods inherited from class java.lang.Object

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

      • classes

        private final com.google.common.collect.ImmutableList<java.lang.Class> classes
        List of classes to scan for operators.
      • cache

        private final com.google.common.cache.LoadingCache<com.google.common.collect.ImmutableSet<SqlLibrary>,​SqlOperatorTable> cache
        A cache that returns an operator table for a given library (or set of libraries).
    • Constructor Detail

      • SqlLibraryOperatorTableFactory

        private SqlLibraryOperatorTableFactory​(java.lang.Class... classes)
    • Method Detail

      • create

        private SqlOperatorTable create​(com.google.common.collect.ImmutableSet<SqlLibrary> librarySet)
        Creates an operator table that contains operators in the given set of libraries.
      • operatorIsInLibrary

        private boolean operatorIsInLibrary​(java.lang.String operatorName,
                                            java.lang.reflect.Field field,
                                            java.util.Set<SqlLibrary> seekLibrarySet)
        Returns whether an operator is in one or more of the given libraries.
      • getOperatorTable

        public SqlOperatorTable getOperatorTable​(SqlLibrary... libraries)
        Returns a SQL operator table that contains operators in the given library or libraries.
      • getOperatorTable

        public SqlOperatorTable getOperatorTable​(java.lang.Iterable<SqlLibrary> librarySet)
        Returns a SQL operator table that contains operators in the given set of libraries.