Package com.sun.codemodel

Examples of com.sun.codemodel.JMethod.param()


    tryBlock._catch(jaxbExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryBlock._catch(fileNotFoundExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    generateUnMarshallerFileFile.body()._return(JExpr._null());

    final JMethod generateUnMarshallerFile = cc.implClass.method(JMod.PUBLIC | JMod.STATIC, kmlClass, "unmarshal");
    generateUnMarshallerFile.param(JMod.FINAL, fileClass, "file");
    generateUnMarshallerFile.javadoc().add("KML to Java\n");
    generateUnMarshallerFile.javadoc().add("KML given as a file object is transformed into a graph of Java objects.\n");
    generateUnMarshallerFile.javadoc().add("Similar to the method: \n");
    generateUnMarshallerFile.javadoc().add("unmarshal(final File, final boolean) \n");
    generateUnMarshallerFile.javadoc().add("with the exception that the File object is not validated (boolean is false). ");
View Full Code Here


  public String generate() throws IOException{
    int i =0;
    for(CodeGeneratorMethod method : sig){
      JMethod m = clazz.method(JMod.PUBLIC, model._ref(method.getReturnType()), method.getMethodName());
      for(CodeGeneratorArgument arg : method){
        m.param(arg.getType(), arg.getName());
      }
      for(Class<?> c : method.getThrowsIterable()){
        m._throws(model.ref(c));
      }
      m._throws(SchemaChangeException.class);
View Full Code Here

      final String propertyName = fieldOutline.getPropertyInfo().getName(true);
      final JClass elementClass = fieldOutline.getRawType().boxify().getTypeParameters().get(0);
      final JPrimitiveType INT = fieldOutline.parent().parent().getCodeModel().INT;

      JMethod method = implClass.method(JMod.PUBLIC, elementClass, "with" + propertyName);
      JVar index = method.param(INT, "index");

      JBlock body = method.body();

      JVar list = body.decl(fieldOutline.getRawType(), "list", JExpr._this().invoke("get" + propertyName));
      JConditional _ifListIsTooSmall = body._if(list.invoke("size").lte(index));
View Full Code Here

        return;
      }
    }

    //It does not exist, therefore let us add the serializer and map it
    JVar param = constructor.param( fieldSerializerType, paramName );

    constructor.body().add( JExpr.invoke( "add" ).arg( param ).invoke( "responsibleFor" ).arg( JExpr.dotclass( fieldType ) )
                              .invoke( "map" )
                              .arg( JExpr.lit( 1 ) ).arg( JExpr.lit( 0 ) ).arg( JExpr.lit( 0 ) )
                              .invoke( "toDelegateVersion" )
View Full Code Here

  protected void createVersionVerifyMethod( @Nonnull JDefinedClass testClass, @Nonnull JClass serializerClass, @Nonnull DomainObjectDescriptor domainObjectDescriptor ) {
    JClass domainType = codeGenerator.ref( domainObjectDescriptor.getQualifiedName() );

    JMethod method = testClass.method( JMod.PROTECTED, Void.TYPE, METHOD_NAME_VERIFY_DESERIALIZED )._throws( Exception.class );
    method.annotate( Override.class );
    JVar deserialized = method.param( domainType, PARAM_NAME_DESERIALIZED );
    method.param( Version.class, PARAM_NAME_VERSION );

    JClass assertClass = codeGenerator.ref( CLASS_NAME_ASSERT );

    for ( FieldWithInitializationInfo fieldInfo : domainObjectDescriptor.getFieldInfos() ) {
View Full Code Here

    JClass domainType = codeGenerator.ref( domainObjectDescriptor.getQualifiedName() );

    JMethod method = testClass.method( JMod.PROTECTED, Void.TYPE, METHOD_NAME_VERIFY_DESERIALIZED )._throws( Exception.class );
    method.annotate( Override.class );
    JVar deserialized = method.param( domainType, PARAM_NAME_DESERIALIZED );
    method.param( Version.class, PARAM_NAME_VERSION );

    JClass assertClass = codeGenerator.ref( CLASS_NAME_ASSERT );

    for ( FieldWithInitializationInfo fieldInfo : domainObjectDescriptor.getFieldInfos() ) {
      method.body().add( assertClass.staticInvoke( METHOD_NAME_ASSERT_EQUALS ).arg( "daValue" ).arg( deserialized.invoke( fieldInfo.getGetterDeclaration().getSimpleName() ) ) );
View Full Code Here

  @Nonnull
  protected JMethod createSerializeMethodStub( @Nonnull JType domainType, @Nonnull JDefinedClass serializerClass ) {
    JMethod serializeMethod = serializerClass.method( JMod.PUBLIC, Void.TYPE, METHOD_NAME_SERIALIZE );
    serializeMethod.annotate( Override.class );
    serializeMethod.param( getSerializeToType(), PARAM_NAME_SERIALIZE_TO );
    serializeMethod.param( domainType, VAR_NAME_OBJECT );
    JVar formatVersion = serializeMethod.param( codeGenerator.ref( Version.class ), PARAM_NAME_FORMAT_VERSION );
    serializeMethod._throws( IOException.class )._throws( ( Class ) getExceptionType() );

    serializeMethod.body().invoke( "verifyVersionWritable" ).arg( formatVersion );
View Full Code Here

  @Nonnull
  protected JMethod createSerializeMethodStub( @Nonnull JType domainType, @Nonnull JDefinedClass serializerClass ) {
    JMethod serializeMethod = serializerClass.method( JMod.PUBLIC, Void.TYPE, METHOD_NAME_SERIALIZE );
    serializeMethod.annotate( Override.class );
    serializeMethod.param( getSerializeToType(), PARAM_NAME_SERIALIZE_TO );
    serializeMethod.param( domainType, VAR_NAME_OBJECT );
    JVar formatVersion = serializeMethod.param( codeGenerator.ref( Version.class ), PARAM_NAME_FORMAT_VERSION );
    serializeMethod._throws( IOException.class )._throws( ( Class ) getExceptionType() );

    serializeMethod.body().invoke( "verifyVersionWritable" ).arg( formatVersion );
View Full Code Here

  protected JMethod createSerializeMethodStub( @Nonnull JType domainType, @Nonnull JDefinedClass serializerClass ) {
    JMethod serializeMethod = serializerClass.method( JMod.PUBLIC, Void.TYPE, METHOD_NAME_SERIALIZE );
    serializeMethod.annotate( Override.class );
    serializeMethod.param( getSerializeToType(), PARAM_NAME_SERIALIZE_TO );
    serializeMethod.param( domainType, VAR_NAME_OBJECT );
    JVar formatVersion = serializeMethod.param( codeGenerator.ref( Version.class ), PARAM_NAME_FORMAT_VERSION );
    serializeMethod._throws( IOException.class )._throws( ( Class ) getExceptionType() );

    serializeMethod.body().invoke( "verifyVersionWritable" ).arg( formatVersion );

    for ( Decorator decorator : codeGenerator.getDecorators() ) {
View Full Code Here

  }

  @Nonnull
  protected JMethod createDeserializeMethodStub( @Nonnull JType domainType, @Nonnull JDefinedClass serializerClass ) {
    JMethod deserializeMethod = serializerClass.method( JMod.PUBLIC, domainType, METHOD_NAME_DESERIALIZE );
    deserializeMethod.param( getSerializeFromType(), METHOD_NAME_DESERIALIZE_FROM );
    JVar formatVersion = deserializeMethod.param( codeGenerator.ref( Version.class ), PARAM_NAME_FORMAT_VERSION );
    deserializeMethod.annotate( Override.class );
    deserializeMethod._throws( IOException.class )._throws( VersionException.class )._throws( ( Class ) getExceptionType() );

    deserializeMethod.body().invoke( "verifyVersionReadable" ).arg( formatVersion );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.