Class FreezableHandler

    • Constructor Detail

      • FreezableHandler

        public FreezableHandler()
    • Method Detail

      • onInitStateful

        public void onInitStateful​(Object proxyInstance,
                                   IBeanTypeMetaInfo<?> metaInfo,
                                   IBeanFactory unused)
        Description copied from interface: ExtensionHandler
        Initialization method for stateful handlers that is called after initialization of the IBean. If a handler is registered as stateful a new instance of the ExtensionHandler implementation is created for each new IBean. After the IBean itself and all handlers created this method is called on all stateful handlers. This method should therefore be overwritten if a handler needs some initialization after creation.

        The default implementation does nothing.

        Specified by:
        onInitStateful in interface ExtensionHandler
        Parameters:
        proxyInstance - the IBean instance
        metaInfo - meta information about the IBean
        unused - the factory that creates the IBean instance
      • interceptSetterCall

        public Object interceptSetterCall​(IBeanContext<?> context,
                                          IBeanFieldMetaInfo fieldMeta,
                                          Object newValue,
                                          Object proxyInstance)
        Description copied from interface: ExtensionHandler
        Called as an optional hook with every setter call on an IBean. Setter calls on IBeans are handled by the IBean implementation itself but an ExtensionHandler can implement this method to hook into the setter call. It can just peak on the new value or it can even change it or throw an exception.

        When you have several extension handlers registered for an IBean type the intercept calls will be called in the order in which the handlers are registered in the ProxyIBeanFactory. See also ProxyIBeanFactory.Builder.withInterfaceSupport(ExtensionSupport).

        The default implementation just returns newValue.

        Specified by:
        interceptSetterCall in interface ExtensionHandler
        Parameters:
        context - provides meta information about the IBean
        fieldMeta - provides meta information about the field related to the setter
        newValue - the current new value of the field. This must not match to the initial value given in the setter call of the IBean as the value might have already been changed by intercept calls from other handlers
        proxyInstance - the IBean instance itself
        Returns:
        the value the field is supposed to be set to. If you do not want to change the value just pass the value provided in newValue
      • freeze

        public Object freeze()
        Description copied from interface: Freezable
        Set the bean to immutable and prevents all further setter calls.
        Specified by:
        freeze in interface Freezable<Object>
        Returns:
        this (the bean itself); used for chaining with setter calls in ModernBeanStyle