@Override public StringBuilder render( StringBuilder sb, int indent ) { indent( sb, indent ); sb.append( "return" ); if( _expr != null ) { sb.append( ' ' ).append( _expr ); } sb.append( ";\n" ); return sb; } }
private void addGetValueMethod( SrcClass srcClass, FqnCacheNode<String> node ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "getValue" ) .modifiers( Modifier.PUBLIC | (isRootProperty( node ) ? Modifier.STATIC : 0) ) .returns( new SrcType( "String" ) ) .body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( String.class, node.getUserData() ) ) ) ); }
private SrcSwitchStatement makeGetValueBynameSwitch( FqnCacheNode<String> node ) { SrcSwitchStatement stmt = new SrcSwitchStatement(); stmt.expr( new SrcIdentifier( "propertyName" ) ); for( FqnCacheNode<String> childNode : node.getChildren() ) { stmt.addCase( new SrcSwitchCase( new SrcType( "String" ), childNode.getName() ) .statement( new SrcReturnStatement( String.class, childNode.getUserData() ) ) ); } return stmt; }
private SrcSwitchStatement makeGetValueBynameSwitch( FqnCacheNode<String> node ) { SrcSwitchStatement stmt = new SrcSwitchStatement(); stmt.expr( new SrcIdentifier( "propertyName" ) ); for( FqnCacheNode<String> childNode : node.getChildren() ) { stmt.addCase( new SrcSwitchCase( new SrcType( "String" ), childNode.getName() ) .statement( new SrcReturnStatement( String.class, childNode.getUserData() ) ) ); } return stmt; }
private void addGetValueMethod( SrcClass srcClass, FqnCacheNode<String> node ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "getValue" ) .modifiers( Modifier.PUBLIC | (isRootProperty( node ) ? Modifier.STATIC : 0) ) .returns( new SrcType( "String" ) ) .body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( String.class, node.getUserData() ) ) ) ); }
private void addToString( SrcClass srcClass ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "toString" ) .modifiers( Modifier.PUBLIC ) .returns( new SrcType( "String" ) ) .body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( new SrcMethodCallExpression( "getValue" ) ) ) ) ); }
.body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( String.class, entry.getValue()._value.toString() ) ) ); method.addAnnotation( makeSourcePositionAnnotation( entry.getKey() ) ); srcClass.addMethod( method );
private void addToString( SrcClass srcClass ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "toString" ) .modifiers( Modifier.PUBLIC ) .returns( new SrcType( "String" ) ) .body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( new SrcMethodCallExpression( "getValue" ) ) ) ) ); }
.body( new SrcStatementBlock() .addStatement( new SrcReturnStatement( String.class, entry.getValue()._value.toString() ) ) ); method.addAnnotation( makeSourcePositionAnnotation( entry.getKey() ) ); srcClass.addMethod( method );
private void addGetValueByNameMethod( SrcClass srcClass, FqnCacheNode<String> node ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "getValueByName" ) .modifiers( Modifier.PUBLIC | (isRootProperty( node ) ? Modifier.STATIC : 0) ) .returns( new SrcType( "String" ) ) .addParam( new SrcParameter( "propertyName" ).type( "String" ) ) .body( new SrcStatementBlock() .addStatement( makeGetValueBynameSwitch( node ) ) .addStatement( new SrcReturnStatement( String.class, null ) ) ) ); }
private void addGetValueByNameMethod( SrcClass srcClass, FqnCacheNode<String> node ) { srcClass.addMethod( new SrcMethod( srcClass ) .name( "getValueByName" ) .modifiers( Modifier.PUBLIC | (isRootProperty( node ) ? Modifier.STATIC : 0) ) .returns( new SrcType( "String" ) ) .addParam( new SrcParameter( "propertyName" ).type( "String" ) ) .body( new SrcStatementBlock() .addStatement( makeGetValueBynameSwitch( node ) ) .addStatement( new SrcReturnStatement( String.class, null ) ) ) ); }