|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Model
A Model is the basic unit of metadata used to drive code generation in JavaGen light. This interface was designed to be as simple as possible to model the structural aspects of code or data. It is also 'light' in the sense that no attempt was made to model behavior.
All models have name, id and ModelType properties.
Each model also has a map of key-value pairs (aka context) allowing arbitrary
values to be associated with a given model instance. Contexts are combined with parent contexts
in such a way that child values override parent values providing a customization mechanism (for
naming patterns for example).
Super classes should be designed as specific as possible to the particular domain they target. When a model from one domain is related or generated from another model instance in another domain use context references to link the two rather than properties that hard-code the two domains together. This keeps the two domains pure and more reusable in other code generation applications.
Models play a second role as templates for customization in conjunction with XML serialization. This only works if properties can be nullable (ie are non-primitive types) and sub classes should stick to this convention.
| Field Summary | |
|---|---|
static String |
DEFAULT_MODEL_TYPE
Default modelType value for generic model instances. |
| Method Summary | |
|---|---|
void |
addChildModel(Model child)
|
List<Model> |
allOwnedModels()
This method is used by the visitor patterns to navigate the model tree hierarchy. |
void |
copyTo(Model target)
Copy non-null properties into target model instance. |
Object |
get(String key)
Convienience method to access the local context of key-value pairs. |
List<Model> |
getChildModels()
|
String |
getId()
Ids are used to serialize Model references and allow fast lookups of unique Model instances. |
String |
getModelType()
A modelType is just that, the type of thing being modeled. |
String |
getName()
A name that describes what is being modeled and forms the basis of the generated artifact names. |
Model |
getParentModel()
A parent is usually the owner or source of the child node. |
Model |
lookupChildByName(String name)
|
void |
put(String key,
Object value)
|
void |
setChildModels(List<Model> childModels)
|
void |
setId(String id)
|
void |
setModelType(String modelType)
|
void |
setName(String name)
|
void |
setParentModel(Model parent)
|
| Methods inherited from interface org.javagen.agile.core.context.ContextHolder |
|---|
getContext |
| Field Detail |
|---|
static final String DEFAULT_MODEL_TYPE
| Method Detail |
|---|
String getName()
lookupChildByName to work effectively.
void setName(String name)
String getId()
void setId(String id)
String getModelType()
void setModelType(String modelType)
Model getParentModel()
void setParentModel(Model parent)
List<Model> getChildModels()
void setChildModels(List<Model> childModels)
void addChildModel(Model child)
Model lookupChildByName(String name)
List<Model> allOwnedModels()
getChildModles.
Object get(String key)
key - a unique string value.
void put(String key,
Object value)
void copyTo(Model target)
target - model to set properties on
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||