/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
/** * Generates statement(s) so that the successive {@link Accessor#ref(boolean)} with * true will always return a non-null list. * * This is useful to avoid generating redundant internal getter. */ protected final void fixNullRef(JBlock block) { block._if(field.eq(JExpr._null()))._then() .assign(field,newCoreList()); }
private void generateCount() { count = cls().method(JMod.PUBLIC, cm.INT, "count"); count().body().decl(cm.INT, "rc", lit(amqpFields.size())); for ( int i = amqpFields.size(); i > 0; i-- ) { JConditional _if = count().body()._if(amqpFields.get(i - 1).attribute.eq(_null())); _if._then().assign(ref("rc"), ref("rc").minus(lit(1))); _if._else()._return(ref("rc")); } count().body()._return(ref("rc")); }
private JMethod generateGetterMethod(JFieldVar field, String fieldName, JExpression defaultValue) { String javaName = NamingHelper.convertToClassName(fieldName); // Add get method JMethod getter = this.pojo.method(JMod.PUBLIC, field.type(), "get" + javaName); if (defaultValue != null) { JBlock body = getter.body(); body._if(field.eq(JExpr._null()))._then()._return(defaultValue); } getter.body()._return(field); getter.javadoc().add("Returns the " + fieldName + "."); getter.javadoc().addReturn().add(field.name()); return getter; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
JBlock delegateNullBlock = delegateCheckMethod.body()._if(delegateField.eq(JExpr._null()))._then();
private void fillInReadMethod() { if ( isComposite() ) { read().body().decl(cm.LONG, "count", cm.ref(generator.getMarshaller() + ".DescribedTypeSupport").staticInvoke("readListHeader").arg(ref("in"))); } Log.info("Filling in read method for %s", type.getName()); for ( Attribute attribute : amqpFields ) { Log.info("%s %s", attribute.type, attribute.attribute.name()); if ( isComposite() ) { read().body().assign(ref("count"), ref("count").minus(lit(1))); JBlock ifBody = read().body()._if(ref("count").gte(lit(0)))._then(); addFieldRead(attribute, ifBody); } else { addFieldRead(attribute, read().body()); } } if ( isComposite() ) { for ( Attribute attribute : amqpFields ) { if ( attribute.required ) { read().body()._if(attribute.attribute.eq(_null()))._then()._throw(_new(cm.ref(RuntimeException.class)).arg("No value specified for mandatory attribute " + attribute.attribute.name())); } } } }
$get.body()._return(ref()); } else { JConditional cond = $get.body()._if(ref().eq(JExpr._null())); cond._then()._return(defaultValue); cond._else()._return(ref());