Class ProxyIBeanFactory.Builder
- java.lang.Object
-
- org.coliper.ibean.proxy.ProxyIBeanFactory.Builder
-
- Enclosing class:
- ProxyIBeanFactory
public static class ProxyIBeanFactory.Builder extends Object
Used for creating new instances ofProxyIBeanFactory.Builders are not created by constructor, they are exclusively created by callingProxyIBeanFactory.builder().ProxyIBeanFactory factory = ProxyIBeanFactory.builder() .withBeanStyle(BeanStyle.MODERN_WITH_OPTIONAL) .withToStringStyle(myToStringStyle) .withDefaultInterfaceSupport() .withInterfaceSupport(extensionSupport1) .withInterfaceSupport(extensionSupport2) .build();Please note that a newly built
ProxyIBeanFactorydoes not contain any extension interface support by default. Even the standard extension interfaces (likeNullSafeorFreezable) are not supported out of the box, you need to usewithDefaultInterfaceSupport()when building the factory.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProxyIBeanFactorybuild()Finally creates the specifiedProxyIBeanFactory.ProxyIBeanFactory.BuilderwithBeanStyle(BeanStyle beanStyle)Determines theBeanStyleto be used in the created factory.ProxyIBeanFactory.BuilderwithBeanStyle(BeanStyle beanStyle, BeanStyleHandler beanStyleHandler)Determines theBeanStyleand its correspondingBeanStyleHandlerto be used in the created factory.ProxyIBeanFactory.BuilderwithDefaultInterfaceSupport()Convenience method that registers all default extension interfaces with their default handlers.ProxyIBeanFactory.BuilderwithInterfaceSupport(ExtensionSupport support)Registers a handler for an extension interface that is supposed to be used in the factory.ProxyIBeanFactory.BuilderwithMetaInfoParser(IBeanMetaInfoParser metaInfoParser)Sets theIBeanMetaInfoParserto be used by the factory.ProxyIBeanFactory.BuilderwithToStringStyle(ToStringStyle toStringStyle)Determines theToStringStyleto be used in the built factory.
-
-
-
Method Detail
-
withMetaInfoParser
public ProxyIBeanFactory.Builder withMetaInfoParser(IBeanMetaInfoParser metaInfoParser)
Sets theIBeanMetaInfoParserto be used by the factory. This method needs to be used only in very rare cases. If not set the factory will use aCachedIBeanMetaInfoParserwhich is best choice for most cases.As a factory uses only one meta parser this method should be called only once for each
Builder. If called multiple times only the last call will take effect.- Parameters:
metaInfoParser- theIBeanMetaInfoParserto be used in the factory- Returns:
- the
Builderinstance itself to enable chained calls
-
withToStringStyle
public ProxyIBeanFactory.Builder withToStringStyle(ToStringStyle toStringStyle)
Determines theToStringStyleto be used in the built factory.As a factory uses only style this method should be called only once for each
Builder. If called multiple times only the last call will take effect.- Parameters:
toStringStyle- either one of the predefined styles found inToStringStyleor a customToStringStyleimplementation- Returns:
- the
Builderinstance itself to enable chained calls
-
withBeanStyle
public ProxyIBeanFactory.Builder withBeanStyle(BeanStyle beanStyle)
Determines theBeanStyleto be used in the created factory.As a factory uses only style this method should be called only once for each
Builder. If called multiple times only the last call will take effect.If you are using a custom
BeanStylethat is not built in, you might need to provide aBeanStyleHandleras well. In that case usewithBeanStyle(BeanStyle, BeanStyleHandler).
-
withBeanStyle
public ProxyIBeanFactory.Builder withBeanStyle(BeanStyle beanStyle, BeanStyleHandler beanStyleHandler)
Determines theBeanStyleand its correspondingBeanStyleHandlerto be used in the created factory. This method should only be used when providing a customBeanStylethat is one of the predefined styles of the IBean framework. If you are using a predefined one likeBeanStyle.CLASSICorBeanStyle.MODERNusedwithBeanStyle(BeanStyle)instead.As a factory uses only style this method should be called only once for each
Builder. If called multiple times only the last call will take effect.- Parameters:
beanStyle- one of the predefined styles inBeanStyleor a customBeanStyleimplementationbeanStyleHandler- theBeanStyleHandlerthat corresponds to the givenbeanStyle- Returns:
- the
Builderinstance itself to enable chained calls
-
withInterfaceSupport
public ProxyIBeanFactory.Builder withInterfaceSupport(ExtensionSupport support)
Registers a handler for an extension interface that is supposed to be used in the factory. This method needs to be called for each extension interface that is supposed to be supported by the factory. If you want to use the default handlers for the built in extension interfaces usewithDefaultInterfaceSupport()as a shortcut.With this method you can determine handler for custom extension interfaces or you can also provide your own handler for one of the built in extension interfaces.
Following sample code registers custom extension interface
ExtInterfacewith handlerExtHandler:ExtensionSupport extSupport = new ExtensionSupport( ExtInterface.class, ExtHandler.class, true); //handler stateful ProxyIBeanFactory factory = ProxyIBeanFactory.builder() .withDefaultInterfaceSupport() .withInterfaceSupport(extSupport) .build();Note: this method should be called only once for each extension support. Multiple calls will overwrite prior settings.
- Parameters:
support- anExtensionSupportthat bundles an extension interface with its handler. All built in handlers already provide anExtensionSupportinstance that can be used to register a built in extension interface with its built in default handler, for exampleNullSafeHandler.SUPPORT. If handler or interface are custom a specificExtensionSupportneeds to be provided.- Returns:
- the
Builderinstance itself to enable chained calls - See Also:
-
IBean overview,
ExtensionSupport,ExtensionHandler (for how to implement custom handlers)
-
withDefaultInterfaceSupport
public ProxyIBeanFactory.Builder withDefaultInterfaceSupport()
Convenience method that registers all default extension interfaces with their default handlers. Should be used instead of callingwithInterfaceSupport(ExtensionSupport)several times.Please note that a newly built
ProxyIBeanFactorydoes not contain any extension interface support by default. Even the standard extension interfaces (likeNullSafeorFreezable) are not supported out of the box, you need to use this method when building the factory.This method should be called only once per factory creation.
- Returns:
- the
Builderinstance itself to enable chained calls
-
build
public ProxyIBeanFactory build()
Finally creates the specifiedProxyIBeanFactory. Although it is meant that per builder instance this method is executed only once and as a final call, it is not prohibited that the factory is modified afterwards with furtherwithXXXcalls and several factories are created. Still this kind of use is discouraged and might be prohibited in future versions.- Returns:
- the newly created factory
-
-