public class DBObjectFactory
extends java.lang.Object
SchemaObjects
and
ChildDBObjects
which may be based on templates and/or
have the initial values of properties defined by
PropertyInitializers
.
The DBObjectFactory supports all SchemaObjects and the following ChildDBObject types
Modifier | Constructor and Description |
---|---|
protected |
DBObjectFactory(DBObjectProvider pro)
Constructor has protected access as API users should retrieve a
factory from the provider, and not instantiate their own.
|
Modifier and Type | Method and Description |
---|---|
protected BaseObjectID |
createID(DBObject obj)
Creates a new BaseObjectID for the given object.
|
protected BaseObjectID |
createID(DBObject obj,
DBObjectID parent)
Creates a new BaseObjectID for the given object.
|
protected void |
ensureBaseInfo(BaseObjectID id,
DBObject obj,
boolean forceName) |
DerivedPropertyBuilder |
ensureDerivedPropertyBuilder(DBObject obj)
If the given object is buildable, and the provider has a derived
property builder for that class of object then this will ensure that
the object has a derived property builder set from this factory's
provider.
|
DBObjectID |
ensureID(DBObject obj,
boolean recurse,
boolean forceNames)
Checks that the given object has an ID that is set up for the factory's
provider.
|
void |
ensureIDs(java.util.Collection<? extends DBObject> objs,
Difference diff)
Checks that all of the given objects that are part of a transaction
have an ID that is set up for the factory's provider.
|
void |
ensureProvider(DBObjectID id)
Initialises the given id's provider to be the factory's provider if it
wasn't already set.
|
void |
ensureSchema(SchemaObject obj)
Ensures that the given object's Schema is the same instance that the
provider has, and not a copy, or separate instance with the same name.
|
java.lang.Object |
getExternalDefaultValue(DBObject obj,
java.lang.String propertyName)
Deprecated.
|
java.lang.Object |
getInitialValue(DBObject obj,
java.lang.String propertyName) |
protected java.util.logging.Logger |
getLogger() |
protected java.lang.String |
getName(DBObject obj,
boolean forceNames) |
protected DBObjectID |
getObjectID(DBObject obj)
As an object's ID should be immutable, DBObject.getID() returns a copy of
the underlying ID.
|
protected DBObjectProvider |
getProvider() |
protected java.util.Collection<DBObjectID> |
getReferenceIDs(DBObject obj)
Gets the existing referenceIDs for the given object without building
any properties that are yet to be built.
|
protected boolean |
isValidID(DBObjectID id) |
<T extends DBObject> |
newObject(java.lang.Class<T> clz)
Creates a new
DBObject of the specified class using the default
template if one exists, and with properties initialized according to all
registered PropertyInitializers . |
<T extends DBObject> |
newObject(java.lang.Class<T> clz,
DBObject parent)
Creates a new
DBObject of the specified class using the default
template if one exists, and with properties initialized according to all
registered PropertyInitializers . |
<T extends DBObject> |
newObject(java.lang.Class<T> clz,
DBObject parent,
boolean useDefaultTemplate)
Creates a new
DBObject of the specified class optionally using the
default template if one exists, and with properties initialized according
to all registered PropertyInitializers . |
<T extends DBObject> |
newObject(java.lang.Class<T> clz,
DBObject parent,
boolean useDefaultTemplate,
boolean initialiseProperties)
Creates a new
DBObject of the specified class optionally using the
default template if one exists, and with properties initialized according
to all registered PropertyInitializers . |
<T extends DBObject> |
newObject(T template)
Creates a new object using the given template with properties initialized
according to all registered
PropertyInitializers , |
<T extends DBObject> |
newObject(T template,
DBObject parent)
Creates a new object using the given template with properties initialized
according to all registered
PropertyInitializers , |
<T extends AbstractBuildableObject> |
setDerivedPropertyBuilder(T obj,
DerivedPropertyBuilder<? super T> builder)
Attempts to set a DerivedPropertyBuilder implementation on the given
object.
|
protected boolean |
useIdentifierBasedIDs(DBObject obj)
Returns true if the given object should be given an IdentifierBasedID
rather than a NameBasedID by the default
createID(oracle.javatools.db.DBObject)
implementation. |
protected DBObjectFactory(DBObjectProvider pro)
protected final DBObjectProvider getProvider()
protected java.util.logging.Logger getLogger()
public <T extends DBObject> T newObject(T template)
PropertyInitializers
,public <T extends DBObject> T newObject(T template, DBObject parent)
PropertyInitializers
,template
- the template to use for the new objectparent
- the parent of the new object - e.g. a Schema for a
new Sequence, a Table for a new column etc.public <T extends DBObject> T newObject(java.lang.Class<T> clz)
DBObject
of the specified class using the default
template if one exists, and with properties initialized according to all
registered PropertyInitializers
.clz
- the class of object to createpublic <T extends DBObject> T newObject(java.lang.Class<T> clz, DBObject parent)
DBObject
of the specified class using the default
template if one exists, and with properties initialized according to all
registered PropertyInitializers
.clz
- the class of object to createparent
- the parent of the new object - e.g. a Schema for a
new Sequence, a Table for a new column etc.public <T extends DBObject> T newObject(java.lang.Class<T> clz, DBObject parent, boolean useDefaultTemplate)
DBObject
of the specified class optionally using the
default template if one exists, and with properties initialized according
to all registered PropertyInitializers
.clz
- the class of object to createparent
- the parent of the new object - e.g. a Schema for a
new Sequence, a Table for a new column etc.useDefaultTemplate
- whether to use the default template from the
provider for the given object type (if such a template is registered)public <T extends DBObject> T newObject(java.lang.Class<T> clz, DBObject parent, boolean useDefaultTemplate, boolean initialiseProperties)
DBObject
of the specified class optionally using the
default template if one exists, and with properties initialized according
to all registered PropertyInitializers
.clz
- the class of object to createparent
- the parent of the new object - e.g. a Schema for a
new Sequence, a Table for a new column etc.useDefaultTemplate
- whether to use the default template from the
provider for the given object type (if such a template is registered)initialiseProperties
- whether to run any registered
PropertyInitializers from the underlying DatabaseDescriptor against
the new object.public final DerivedPropertyBuilder ensureDerivedPropertyBuilder(DBObject obj)
Recurses to all existing owned objects in the hierarchy without building any extra properties.
obj
- the object to ensure has a derived property builderpublic <T extends AbstractBuildableObject> boolean setDerivedPropertyBuilder(T obj, DerivedPropertyBuilder<? super T> builder)
obj
- the object to set the builder on.builder
- the DerivedPropertyBuilder implementation to set on the
object.@Deprecated public java.lang.Object getExternalDefaultValue(DBObject obj, java.lang.String propertyName)
PropertyManager.getImplicitDefaultValue(oracle.javatools.db.DBObject, java.lang.String)
public java.lang.Object getInitialValue(DBObject obj, java.lang.String propertyName)
PropertyInitializers
public void ensureSchema(SchemaObject obj)
It is only anticipated that this method will be needed internally.
obj
- the SchemaObject to check the Schema forpublic void ensureIDs(java.util.Collection<? extends DBObject> objs, Difference diff)
It is only anticipated that this method will be needed internally.
objs
- the objects to ensure have valid IDs.diff
- the transaction difference the objects have come from.public DBObjectID ensureID(DBObject obj, boolean recurse, boolean forceNames)
It is only anticipated that this method will be needed internally.
obj
- the object to ensure has a valid ID for this factory's providerrecurse
- whether to recurse and process the objects' child objects
as wellforceNames
- if true this will additionally set the name based
information on identifier based IDs. This is a potentially more time
consuming operation as it may require dependent objects to be loaded.protected boolean isValidID(DBObjectID id)
protected boolean useIdentifierBasedIDs(DBObject obj)
createID(oracle.javatools.db.DBObject)
implementation.obj
- the object that needs a new idprotected BaseObjectID createID(DBObject obj)
obj
- the object that needs a new idprotected BaseObjectID createID(DBObject obj, DBObjectID parent)
obj
- the object that needs a new idprotected void ensureBaseInfo(BaseObjectID id, DBObject obj, boolean forceName)
protected final java.lang.String getName(DBObject obj, boolean forceNames)
public final void ensureProvider(DBObjectID id)
protected final DBObjectID getObjectID(DBObject obj)
protected final java.util.Collection<DBObjectID> getReferenceIDs(DBObject obj)
obj
- the object to get any existing DBObjectID property values
for