public ModelDefault getDefault( String key ) { ModelDefault modelDefault = (ModelDefault) defaultMap.get( key ); if ( modelDefault == null ) { try { modelDefault = ModelDefault.getDefault( key ); } catch ( ModelValidationException mve ) { throw new ModelloRuntimeException( mve.getMessage(), mve ); } } return modelDefault; }
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 + "." ); } }
new MojoExecutionException( "Error generating: " + e.getMessage(), e );
private static void validateKey( String key ) throws ModelValidationException { if ( ! SET.equalsIgnoreCase( key ) && ! LIST.equalsIgnoreCase( key ) && ! MAP.equalsIgnoreCase( key ) && ! PROPERTIES.equalsIgnoreCase( key ) && ! CHECK_DEPRECATION.equalsIgnoreCase( key ) && ! PACKAGE.equalsIgnoreCase( key ) && ! STRICT_XML_ATTRIBUTES.equalsIgnoreCase( key ) ) { throw new ModelValidationException( "The key of default element must be ' " + SET + "', '" + LIST + "', '" + MAP + "', '" + PROPERTIES + "', '" + CHECK_DEPRECATION + "', '" + PACKAGE + "' or '" + STRICT_XML_ATTRIBUTES + "', was '" + key + "'." ); } }
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 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 + "'." ); } }
throw new ModelValidationException( "You must define the type of association." ); throw new ModelValidationException( "Association '" + getName() + "': Could not find to class." ); throw new ModelValidationException( "Association multiplicity '" + getName() + "' is incorrect: " + "Possible values are '1', '*' or 'n'." ); throw new ModelValidationException( "The type of element '" + getName() + "' must be List, Map, Properties or Set." );
public void validateElement() throws ModelValidationException { // Check if superClass exists if ( hasSuperClass() ) { try { getModel().getClass( superClass, getVersionRange() ); isInternalSuperClass = true; } catch ( ModelloRuntimeException e ) { isInternalSuperClass = false; } } if ( getModel().getDefault( ModelDefault.CHECK_DEPRECATION ).getBoolean() ) { if ( ! Version.INFINITE.equals( getVersionRange().getToVersion() ) && getDeprecatedVersion() == null ) { throw new ModelValidationException( "You must define the deprecated version of '" + getName() + "' class." ); } } }