public String getDefaultPackageName( boolean withVersion, Version version ) { String packageName = getDefault( ModelDefault.PACKAGE ).getValue(); if ( withVersion ) { packageName += "." + version.toString( "v", "_" ); } return packageName; }
public void initialize( Model model ) { super.initialize( model ); for ( ModelField modelField : getAllFields() ) { modelField.initialize( this ); } }
protected void validateFieldNotEmpty( String objectName, String fieldName, String value ) throws ModelValidationException { if ( value == null ) { throw new ModelValidationException( "Missing value '" + fieldName + "' from " + objectName + "." ); } if ( isEmpty( value ) ) { throw new ModelValidationException( "Empty value '" + fieldName + "' from " + objectName + "." ); } }
public boolean isModelVersionField() { Model model = modelClass.getModel(); VersionDefinition versionDefinition = model.getVersionDefinition(); return ( versionDefinition != null ) && versionDefinition.isFieldType() && ( versionDefinition.getValue().equals( getName() ) || versionDefinition.getValue().equals( alias ) ); } }
public void validateElement() throws ModelValidationException { validateFieldNotEmpty( "field", "name", getName() ); validateFieldNotEmpty( "field '" + getName() + "'", "type", type ); // TODO: these definitions are duplicated throughout. Defined centrally, and loop through in the various uses if ( !isPrimitive() && !isPrimitiveArray() ) { throw new ModelValidationException( "Field '" + getName() + "': Illegal type: '" + type + "'." ); } }
public ModelClass getClass( String type, Version version ) { return getClass( type, new VersionRange( version ), false ); }
protected boolean isClassInModel( String fieldType, Model model ) { try { return model.getClass( fieldType, generatedVersion ) != null; } catch ( Exception e ) { } return false; }
/** * @deprecated This shouldn't be used, anything querying the model should read the * package of the class. Use getDefaultPackageName(..). */ public String getPackageName( boolean withVersion, Version version ) { return getDefaultPackageName( withVersion, version ); }
protected void initialize( Model model, Properties parameters ) throws ModelloException { super.initialize( model, parameters ); strictXmlAttributes = model.getDefault( ModelDefault.STRICT_XML_ATTRIBUTES ).getBoolean(); }
public static boolean isInConflict( VersionRange version1, VersionRange version2 ) { return !( version1.getToVersion().lesserThan( version2.getFromVersion() ) || version2.getToVersion().lesserThan( version1.getFromVersion() ) ); } }
public void validateElement() throws ModelValidationException { if ( isEmpty( key ) ) { throw new ModelValidationException( "You must define the key of default element." ); } if ( isEmpty( value ) ) { throw new ModelValidationException( "You must define the value of default element." ); } validateKey( key ); }
public ModelInterface getInterface( String type, Version version ) { return getInterface( type, new VersionRange( version ) ); }
public boolean hasField( String type, Version version ) { try { getField( type, new VersionRange( version ) ); return true; } catch ( Exception e ) { return false; } }
public boolean hasClass( String type, Version version ) { ModelClass value = getModelClass( type, new VersionRange( version ) ); return value != null; }
public void initialize() { for ( ModelClass modelClass : classes ) { modelClass.initialize( this ); } for ( ModelInterface modelInterface : interfaces ) { modelInterface.initialize( this ); } }
public ModelType getType( String type, Version version ) { return getType( type, new VersionRange( version ) ); }
public List<CodeSegment> getCodeSegments( Version version ) { return getCodeSegments( new VersionRange( version ) ); }
public final void validate() throws ModelValidationException { if ( nameRequired ) { validateFieldNotEmpty( "Element.name", "name", name ); } validateElement(); }
public ModelClass getClass( String type, Version version, boolean optionnal ) { return getClass( type, new VersionRange( version ), optionnal ); }
public ModelField getField( String type, Version version ) { return getField( type, new VersionRange( version ) ); }