public void initialize( Model model ) { super.initialize( model ); for ( ModelField modelField : getAllFields() ) { modelField.initialize( this ); } }
/** * Returns all the fields in this class and all super classes if withInheritedField equals to true. * * @return Returns all the fields in this class and all super classes. */ public List<ModelField> getAllFields( boolean withInheritedField ) { if ( ! withInheritedField ) { return getAllFields(); } List<ModelField> fields = new ArrayList<ModelField>( getAllFields() ); ModelClass c = this; while ( c.hasSuperClass() && c.isInternalSuperClass() ) { ModelClass parent = getModel().getClass( c.getSuperClass(), getVersionRange() ); fields.addAll( parent.getAllFields() ); c = parent; } return fields; }
public void addField( ModelField modelField ) { if ( fieldMap.containsKey( modelField.getName() ) ) { List<ModelField> fieldList = fieldMap.get( modelField.getName() ); for ( ModelField currentField : fieldList ) { if ( VersionUtil.isInConflict( modelField.getVersionRange(), currentField.getVersionRange() ) ) { throw new ModelloRuntimeException( "Duplicate field in " + getName() + ": " + modelField.getName() + "." ); } } } else { List<ModelField> fieldList = new ArrayList<ModelField>(); fieldMap.put( modelField.getName(), fieldList ); } getAllFields().add( modelField ); fieldMap.get( modelField.getName() ).add( modelField ); }
/** * Add code to parse fields of a model class that are XML attributes. * * @param modelClass the model class * @param uncapClassName * @param sc the source code to add to * @throws ModelloException */ private void writeAttributes( ModelClass modelClass, String uncapClassName, JSourceCode sc ) throws ModelloException { for ( ModelField field : modelClass.getAllFields( getGeneratedVersion(), true ) ) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata( XmlFieldMetadata.ID ); if ( xmlFieldMetadata.isAttribute() && !xmlFieldMetadata.isTransient() ) { writePrimitiveField( field, field.getType(), uncapClassName, "set" + capitalise( field.getName() ), sc ); } } }
/** * Validate the entire model. * * @throws ModelValidationException */ private void validate( Model model ) throws ModelValidationException { model.validate(); for ( ModelDefault modelDefault : model.getDefaults() ) { modelDefault.validateElement(); } for ( ModelClass modelClass : model.getAllClasses() ) { modelClass.validate(); } for ( ModelClass modelClass : model.getAllClasses() ) { for ( ModelField field : modelClass.getAllFields() ) { field.validate(); } for ( CodeSegment codeSegment : modelClass.getAllCodeSegments() ) { codeSegment.validate(); } } }
for ( ModelField field : clazz.getAllFields() )
"attribute 'xml.schemaLocation' for class element is deprecated: it should be moved to model element" ); for ( ModelField field : clazz.getAllFields() )
for ( ModelField field : modelClass.getAllFields( getGeneratedVersion(), true ) )
ModelField contentField = getContentField( modelClass.getAllFields( getGeneratedVersion(), true ) ); for ( ModelField field : modelClass.getAllFields( getGeneratedVersion(), true ) )