public static class ProxyIBeanFactory.Builder extends Object
ProxyIBeanFactory.
Builders are not created by constructor, they are exclusively
created by calling ProxyIBeanFactory.builder().
ProxyIBeanFactory factory = ProxyIBeanFactory.builder()
.withBeanStyle(BeanStyle.MODERN_WITH_OPTIONAL)
.withToStringStyle(myToStringStyle)
.withDefaultInterfaceSupport()
.withInterfaceSupport(extensionSupport1)
.withInterfaceSupport(extensionSupport2)
.build();
Please note that a newly built ProxyIBeanFactory does not contain any
extension interface support by default. Even the standard extension interfaces (like
NullSafe or Freezable) are not supported out of the box, you need to
use withDefaultInterfaceSupport() when building the factory.
| Modifier and Type | Method and Description |
|---|---|
ProxyIBeanFactory |
build()
Finally creates the specified
ProxyIBeanFactory. |
ProxyIBeanFactory.Builder |
withBeanStyle(BeanStyle beanStyle)
Determines the
BeanStyle to be used in the created factory. |
ProxyIBeanFactory.Builder |
withBeanStyle(BeanStyle beanStyle,
BeanStyleHandler beanStyleHandler)
Determines the
BeanStyle and its corresponding
BeanStyleHandler to be used in the created factory. |
ProxyIBeanFactory.Builder |
withDefaultInterfaceSupport()
Convenience method that registers all default extension interfaces
with their default handlers.
|
ProxyIBeanFactory.Builder |
withInterfaceSupport(ExtensionSupport support)
Registers a handler for an extension interface that is supposed to be used in the
factory.
|
ProxyIBeanFactory.Builder |
withMetaInfoParser(IBeanMetaInfoParser metaInfoParser)
Sets the
IBeanMetaInfoParser to be used by the factory. |
ProxyIBeanFactory.Builder |
withToStringStyle(ToStringStyle toStringStyle)
Determines the
ToStringStyle to be used in the built factory. |
public ProxyIBeanFactory.Builder withMetaInfoParser(IBeanMetaInfoParser metaInfoParser)
IBeanMetaInfoParser to be used by the factory. This
method needs to be used only in very rare cases. If not set the
factory will use a CachedIBeanMetaInfoParser which 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.
metaInfoParser - the IBeanMetaInfoParser to be used in the factoryBuilder instance itself to enable chained callspublic ProxyIBeanFactory.Builder withToStringStyle(ToStringStyle toStringStyle)
ToStringStyle to 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.
toStringStyle - either one of the predefined styles found in
ToStringStyle or a custom ToStringStyle
implementationBuilder instance itself to enable chained callspublic ProxyIBeanFactory.Builder withBeanStyle(BeanStyle beanStyle)
BeanStyle to 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 BeanStyle that is not built
in, you might need to provide a BeanStyleHandler as well. In
that case use withBeanStyle(BeanStyle, BeanStyleHandler).
public ProxyIBeanFactory.Builder withBeanStyle(BeanStyle beanStyle, BeanStyleHandler beanStyleHandler)
BeanStyle and its corresponding
BeanStyleHandler to be used in the created factory. This
method should only be used when providing a custom
BeanStyle that is one of the predefined styles of the
IBean framework. If you are using a predefined one like
BeanStyle.CLASSIC or BeanStyle.MODERN used
withBeanStyle(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.
beanStyle - one of the predefined styles in BeanStyle or a
custom BeanStyle implementationbeanStyleHandler - the BeanStyleHandler that corresponds to the given
beanStyleBuilder instance itself to enable chained callspublic ProxyIBeanFactory.Builder withInterfaceSupport(ExtensionSupport support)
withDefaultInterfaceSupport()
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 ExtInterface with
handler ExtHandler:
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.
support - an ExtensionSupport that bundles an extension interface with
its handler. All built in handlers already provide an ExtensionSupport
instance that can be used to register a built in extension interface with its
built in default handler, for example NullSafeHandler.SUPPORT.
If handler or interface are custom a specific ExtensionSupport needs to be
provided.Builder instance itself to enable chained callsExtensionSupport,
ExtensionHandler (for how to implement custom handlers)public ProxyIBeanFactory.Builder withDefaultInterfaceSupport()
withInterfaceSupport(ExtensionSupport) several times.
Please note that a newly built ProxyIBeanFactory does not
contain any extension interface support by default. Even the standard
extension interfaces (like NullSafe or Freezable) 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.
Builder instance itself to enable chained callspublic ProxyIBeanFactory build()
ProxyIBeanFactory. 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 further withXXX calls and several
factories are created. Still this kind of use is discouraged and
might be prohibited in future versions.