org.apache.cayenne.util

## Class NamedObjectFactory

- java.lang.Object
- - org.apache.cayenne.util.NamedObjectFactory

-     public abstract class NamedObjectFactory
      extends Object

  Factory class that generates various Cayenne objects with default names that are unique in their corresponding context. Supports creation of the following objects:
  - DataMap
  - ObjEntity
  - ObjAttribute
  - ObjRelationship
  - DbEntity
  - DbAttribute
  - DbRelationship
  - DataNodeDescriptor
  - DataDomain
  - Query
  - Procedure
  - ProcedureParameter
  This is a helper class used mostly by GUI and database reengineering classes.
  Since:
    3.1 moved from project package

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NamedObjectFactory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Object` | `create(String name, Object namingContext)` Internal factory method.
    `static String` | `createName(Class objectClass, Object namingContext)`
    `static String` | `createName(Class objectClass, Object namingContext, String nameBase)`
    `static Object` | `createObject(Class<? extends DataMap> objectClass, Object namingContext, String nameBase)`
    `static Object` | `createObject(Class objectClass, Object namingContext)` Creates an object using an appropriate factory class.
    `static Relationship` | `createRelationship(Entity srcEnt, Entity targetEnt, boolean toMany)` Creates a relationship using an appropriate factory class.
    `protected abstract boolean` | `isNameInUse(String name, Object namingContext)` Checks if the name is already taken by another sibling in the same context.
    `protected String` | `makeName(Object namingContext)` Creates a unique name for the new object and constructs this object.
    `protected String` | `makeName(Object namingContext, String nameBase)`
    `protected Object` | `makeObject(Object namingContext)` Creates a unique name for the new object and constructs this object.
    `protected Object` | `makeObject(Object namingContext, String nameBase)`
    `protected abstract String` | `nameBase()` Returns a base default name, like "UntitledEntity", etc.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NamedObjectFactory

          public NamedObjectFactory()

  - ### Method Detail

    - #### createName

          public static String createName(Class objectClass,
                                          Object namingContext)

    - #### createName

          public static String createName(Class objectClass,
                                          Object namingContext,
                                          String nameBase)

      Since:
        1.0.5

    - #### createObject

          public static Object createObject(Class objectClass,
                                            Object namingContext)

      Creates an object using an appropriate factory class. If no factory is found for the object, NullPointerException is thrown.

      Note that newly created object is not added to the parent. This behavior can be changed later.

    - #### createObject

          public static Object createObject(Class<? extends DataMap> objectClass,
                                            Object namingContext,
                                            String nameBase)

      Since:
        1.0.5

    - #### createRelationship

          public static Relationship createRelationship(Entity srcEnt,
                                                        Entity targetEnt,
                                                        boolean toMany)

      Creates a relationship using an appropriate factory class. If no factory is found for the object, NullPointerException is thrown.

      Note that newly created object is not added to the parent. This behavior can be changed later.

    - #### makeName

          protected String makeName(Object namingContext)

      Creates a unique name for the new object and constructs this object.

    - #### makeName

          protected String makeName(Object namingContext,
                                    String nameBase)

      Since:
        1.0.5

    - #### makeObject

          protected Object makeObject(Object namingContext)

      Creates a unique name for the new object and constructs this object.

    - #### makeObject

          protected Object makeObject(Object namingContext,
                                      String nameBase)

      Since:
        1.0.5

    - #### nameBase

          protected abstract String nameBase()

      Returns a base default name, like "UntitledEntity", etc.

    - #### create

          protected abstract Object create(String name,
                                           Object namingContext)

      Internal factory method. Invoked after the name is figured out.

    - #### isNameInUse

          protected abstract boolean isNameInUse(String name,
                                                 Object namingContext)

      Checks if the name is already taken by another sibling in the same context.

Copyright © 2001–2017 Apache Cayenne. All rights reserved.