com.sun.codemodel.internal.JConditional Java Examples

The following examples show how to use com.sun.codemodel.internal.JConditional. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementCollectionAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #2
Source File: ElementCollectionAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #3
Source File: ElementCollectionAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #4
Source File: ElementCollectionAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #5
Source File: ElementCollectionAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #6
Source File: ElementCollectionAdapter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #7
Source File: ElementCollectionAdapter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #8
Source File: ElementCollectionAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $var = new ArrayList();
    // for( JAXBElement e : [core.toRawValue] ) {
    //   if(e==null)
    //     $var.add(null);
    //   else
    //     $var.add(e.getValue());
    // }

    block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
    JVar $col = block.decl(core.getRawType(), "col" + hashCode());
    acc.toRawValue(block,$col);
    JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

    JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
    cond._then().invoke($var,"add").arg(JExpr._null());
    cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
}
 
Example #9
Source File: ServiceGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #10
Source File: ElementSingleAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #11
Source File: ServiceGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #12
Source File: ServiceGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #13
Source File: ServiceGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #14
Source File: ServiceGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #15
Source File: ElementSingleAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #16
Source File: ElementSingleAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #17
Source File: ServiceGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #18
Source File: ElementSingleAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #19
Source File: ServiceGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #20
Source File: ServiceGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #21
Source File: ServiceGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #22
Source File: ServiceGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #23
Source File: ServiceGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #24
Source File: ElementSingleAdapter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #25
Source File: ServiceGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #26
Source File: ServiceGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #27
Source File: ElementSingleAdapter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #28
Source File: ElementSingleAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}
 
Example #29
Source File: ServiceGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
    JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
    ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
            "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
    staticBlock.assign(exField, exVar);
}
 
Example #30
Source File: ElementSingleAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void toRawValue(JBlock block, JVar $var) {
    // [RESULT]
    // if([core.hasSetValue])
    //   $var = [core.toRawValue].getValue();
    // else
    //   $var = null;

    JConditional cond = block._if(acc.hasSetValue());
    JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control
    acc.toRawValue(cond._then(),$v);
    cond._then().assign($var,$v.invoke("getValue"));
    cond._else().assign($var, JExpr._null());
}