Top Description Inners Fields Constructors Methods
org.jboss.logmanager.configuration

pack-priv Class ObjectBuilder<T>

extends Object
Class Inheritance
Annotations
@SuppressWarnings:UnusedReturnValue
Imports
java.lang.reflect.Constructor, .Method, .Modifier, java.nio.charset.Charset, java.util.Collections, .LinkedHashMap, .LinkedHashSet, .Map, .Set, .TimeZone, java.util.function.Supplier, java.util.logging.Level, java.util.regex.Pattern, org.jboss.modules.Module, .ModuleLoader

Helper to lazily build an object.
Author
James R. Perkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private final Class<? extends T>
private final String
private final Map<String, String>
private final ContextConfiguration
private final Set<ObjectBuilder.PropertyValue>
private String
private final Set<String>
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
private
ObjectBuilder(final ContextConfiguration contextConfiguration, final Class<? extends T> baseClass, final String className)

Method Summary

Modifier and TypeMethod and Description
pack-priv ObjectBuilder<T>

Returns:

this builder
addConstructorProperty
(final String
the name of the property
name
,
final String
a string representing the value
value
)

Adds a property used for constructing the object.

pack-priv ObjectBuilder<T>

Returns:

this builder
addDefinedProperty
(final String
the name of the property
name
,
final Class<?>
the type of the property
type
,
final Supplier<?>
a supplier for the property value
value
)

Adds a defined property to be set after the object is created.

pack-priv ObjectBuilder<T>

Returns:

this builder
addPostConstructMethods
(final String...
the name of the method to execute
methodNames
)

Adds a method name to be executed after the object is created and the properties are set.

pack-priv ObjectBuilder<T>

Returns:

this builder
addProperty
(final String
the name of the property
name
,
final String
a string representing the value
value
)

Adds a property to be set on the object after it has been created.

pack-priv Supplier<T>

Returns:

a supplier which can create the object
build
()

Creates a the object when the supplier value is accessed.

private boolean
private ObjectBuilder.PropertyValue
private static Class<?>
getConstructorPropertyType(Class<?> clazz, String propertyName)

private static Method
getPropertyGetter(Class<?> clazz, String propertyName)

private static Method
getPropertySetter(Class<?> clazz, String propertyName)

private static String
getPropertySetterName(final String propertyName)

private static Class<?>
getPropertyType(Class<?> clazz, String propertyName)

private static Class<?>
getPropertyType(final Method setter)

private Object
getValue(final Class<?> objClass, final String propertyName, final Class<?> paramType, final String value)

pack-priv static <
the type being created
T
>
ObjectBuilder<T>

Returns:

a new ObjectBuilder
of
(final ContextConfiguration contextConfiguration, final Class<? extends T>
the base type
baseClass
,
final String
the name of the class to create
className
)

Create a new ObjectBuilder.

pack-priv ObjectBuilder<T>

Returns:

this builder
setModuleName
(final String
the module name or null to use this class loader
moduleName
)

Sets the name of the module used to load the object being created.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseClassback to summary
private final Class<? extends T> baseClass
classNameback to summary
private final String className
constructorPropertiesback to summary
private final Map<String, String> constructorProperties
contextConfigurationback to summary
private final ContextConfiguration contextConfiguration
definedPropertiesback to summary
private final Set<ObjectBuilder.PropertyValue> definedProperties
moduleNameback to summary
private String moduleName
postConstructMethodsback to summary
private final Set<String> postConstructMethods
propertiesback to summary
private final Map<String, String> properties

Constructor Detail

ObjectBuilderback to summary
private ObjectBuilder(final ContextConfiguration contextConfiguration, final Class<? extends T> baseClass, final String className)

Method Detail

addConstructorPropertyback to summary
pack-priv ObjectBuilder<T> addConstructorProperty(final String name, final String value)

Adds a property used for constructing the object.

The name must be the base name for a getter or setter so the type can be determined.

Parameters
name:String

the name of the property

value:String

a string representing the value

Returns:ObjectBuilder<T>

this builder

addDefinedPropertyback to summary
pack-priv ObjectBuilder<T> addDefinedProperty(final String name, final Class<?> type, final Supplier<?> value)

Adds a defined property to be set after the object is created.

Parameters
name:String

the name of the property

type:Class<?>

the type of the property

value:Supplier<?>

a supplier for the property value

Returns:ObjectBuilder<T>

this builder

addPostConstructMethodsback to summary
pack-priv ObjectBuilder<T> addPostConstructMethods(final String... methodNames)

Adds a method name to be executed after the object is created and the properties are set. The method must not have any parameters.

Parameters
methodNames:String[]

the name of the method to execute

Returns:ObjectBuilder<T>

this builder

addPropertyback to summary
pack-priv ObjectBuilder<T> addProperty(final String name, final String value)

Adds a property to be set on the object after it has been created.

Parameters
name:String

the name of the property

value:String

a string representing the value

Returns:ObjectBuilder<T>

this builder

buildback to summary
pack-priv Supplier<T> build()

Creates a the object when the supplier value is accessed.

Returns:Supplier<T>

a supplier which can create the object

definedPropertiesContainsback to summary
private boolean definedPropertiesContains(final String name)
findDefinedPropertyback to summary
private ObjectBuilder.PropertyValue findDefinedProperty(final String name)
getConstructorPropertyTypeback to summary
private static Class<?> getConstructorPropertyType(Class<?> clazz, String propertyName)
getPropertyGetterback to summary
private static Method getPropertyGetter(Class<?> clazz, String propertyName)
getPropertySetterback to summary
private static Method getPropertySetter(Class<?> clazz, String propertyName)
getPropertySetterNameback to summary
private static String getPropertySetterName(final String propertyName)
getPropertyTypeback to summary
private static Class<?> getPropertyType(Class<?> clazz, String propertyName)
getPropertyTypeback to summary
private static Class<?> getPropertyType(final Method setter)
getValueback to summary
private Object getValue(final Class<?> objClass, final String propertyName, final Class<?> paramType, final String value)
ofback to summary
pack-priv static <T> ObjectBuilder<T> of(final ContextConfiguration contextConfiguration, final Class<? extends T> baseClass, final String className)

Create a new ObjectBuilder.

Parameters
<T>
the type being created
baseClass:Class<? extends T>

the base type

className:String

the name of the class to create

Returns:ObjectBuilder<T>

a new ObjectBuilder

setModuleNameback to summary
pack-priv ObjectBuilder<T> setModuleName(final String moduleName)

Sets the name of the module used to load the object being created.

Parameters
moduleName:String

the module name or null to use this class loader

Returns:ObjectBuilder<T>

this builder

org.jboss.logmanager.configuration back to summary

pack-priv Class ObjectBuilder.ModuleFinder

extends Object
Class Inheritance
  • java.lang.Object
  • org.jboss.logmanager.configuration.ObjectBuilder.ModuleFinder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static ClassLoader
getClassLoader(final String moduleName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ModuleFinderback to summary
private ModuleFinder()

Method Detail

getClassLoaderback to summary
pack-priv static ClassLoader getClassLoader(final String moduleName) throws Exception
org.jboss.logmanager.configuration back to summary

private Class ObjectBuilder.ModuleFinder.Holder

extends Object
Class Inheritance
  • java.lang.Object
  • org.jboss.logmanager.configuration.ObjectBuilder.ModuleFinder.Holder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static ClassLoader
getClassLoader(final String moduleName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Holderback to summary
private Holder()

Method Detail

getClassLoaderback to summary
pack-priv static ClassLoader getClassLoader(final String moduleName) throws Exception
org.jboss.logmanager.configuration back to summary

private Class ObjectBuilder.PropertyValue

extends Object
implements Comparable<ObjectBuilder.PropertyValue>
Class Inheritance
  • java.lang.Object
  • org.jboss.logmanager.configuration.ObjectBuilder.PropertyValue
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
pack-priv final String
pack-priv final Class<?>
pack-priv final Supplier<?>

Constructor Summary

AccessConstructor and Description
private
PropertyValue(final String name, final Class<?> type, final Supplier<?> value)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final ObjectBuilder.PropertyValue
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
pack-priv final String name
typeback to summary
pack-priv final Class<?> type
valueback to summary
pack-priv final Supplier<?> value

Constructor Detail

PropertyValueback to summary
private PropertyValue(final String name, final Class<?> type, final Supplier<?> value)

Method Detail

compareToback to summary
public int compareTo(final ObjectBuilder.PropertyValue o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
o:ObjectBuilder.PropertyValue

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override