Class IContextExtensions


  • public class IContextExtensions
    extends Object
    Meta-programming extensions to the IContext class.
    Author:
    Emanuel Rabina
    • Constructor Detail

      • IContextExtensions

        public IContextExtensions()
    • Method Detail

      • getAt

        public static Object getAt​(IContext self,
                                   String name)
        Enables use of the value = context[key] syntax over the context object, is a synonym for the getVariable method.
        Parameters:
        self -
        name - Name of the variable on the context to retrieve.
        Returns:
        The variable value, or null if the variable isn't mapped to anything on the context.
      • getOrCreate

        public static <T> T getOrCreate​(@Nonnull
                                        IContext self,
                                        @Nonnull
                                        String key,
                                        Supplier<T> closure)
        Retrieves an item from the context, or creates one on the context if it doesn't yet exist.
        Type Parameters:
        T -
        Parameters:
        self -
        key -
        closure -
        Returns:
        The item cached on the context through the given key, or first constructed through the closure.
      • getPrefixForDialect

        public static String getPrefixForDialect​(@Nonnull
                                                 IContext self,
                                                 Class<? extends IProcessorDialect> dialectClass)
        Returns the configured prefix for the given dialect. If the dialect prefix has not been configured.
        Parameters:
        self -
        dialectClass -
        Returns:
        The configured prefix for the dialect, or null if the dialect being queried hasn't been configured.
      • putAt

        public static void putAt​(IContext self,
                                 String name,
                                 Object value)
        Enables use of the context[key] = value syntax over the context object, is a synonym for the setVariable method.
        Parameters:
        self -
        name - Name of the variable to map the value to.
        value - The value to set.