public final JExpression dotclass() { return JExpr.dotclass(this); }
private JInvocation packageName(final JDefinedClass bean) { return JExpr.dotclass(bean).invoke("getPackage").invoke("getName"); } }
@Override @Nonnull public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) { JClass collectionParamType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() ); JInvocation nextTagExpression = createNextTagInvocation( serializerClass, deserializeFrom, fieldInfo ); JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE_COLLECTION ).arg( deserializeFrom ).arg( JExpr.dotclass( collectionParamType ) ).arg( formatVersion ); return new Expressions( expression, nextTagExpression ); }
@Nonnull @Override public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) { JInvocation nextTagExpression = createNextTagInvocation( serializerClass, deserializeFrom, fieldInfo ); JClass type = codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() ); JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( type ) ).arg( formatVersion ).arg( deserializeFrom ); return new Expressions( expression, nextTagExpression ); }
private void createToDebugType(JDefinedClass definedClass) { JMethod method = definedClass.method(JMod.PUBLIC, String.class, "toDebugType"); method.annotate(CLASS_MAP.get(Override.class)); JBlock body = method.body(); JVar builder = body.decl(CLASS_MAP.get(StringBuilder.class), "builder", JExpr._new(CLASS_MAP.get(StringBuilder.class))); invokeAppendOnBuilder(body, builder, JExpr.dotclass(definedClass).invoke("getSimpleName")); body._return(JExpr.invoke(builder, "toString")); }
private JInvocation newJaxBElement(JVar xsrVar, Class type, JExpression expression) { if (JAXBElement.class.equals(type)) { throw new IllegalArgumentException("Can't wrap a JAXBElement with a JAXBElement"); } JType jaxbElementType = context.toJClass(JAXBElement.class).narrow(type); JInvocation newJaxBElement = JExpr._new(jaxbElementType) .arg(xsrVar.invoke("getName")) .arg(JExpr.dotclass(context.toJClass(type))) .arg(expression); return newJaxBElement; }
private JInvocation newJaxBElement(JVar xsrVar, Class type, JExpression expression) { if (JAXBElement.class.equals(type)) { throw new IllegalArgumentException("Can't wrap a JAXBElement with a JAXBElement"); } JType jaxbElementType = context.toJClass(JAXBElement.class).narrow(type); JInvocation newJaxBElement = JExpr._new(jaxbElementType) .arg(xsrVar.invoke("getName")) .arg(JExpr.dotclass(context.toJClass(type))) .arg(expression); return newJaxBElement; }
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 generateHashCode() { hashCode = cls().method(JMod.PUBLIC, cm.INT, "hashCode"); hashCode.body().block()._if(_this().ref("value").eq(_null())) ._then() ._return(dotclass(cls()).invoke("hashCode")); hashCode.body().block()._return(_this().ref("value").invoke("hashCode")); }
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 writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null()); JTryBlock tryBlock = staticBlock._try(); tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation)); JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class)); JVar murlVar = catchBlock.param("murl"); catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar)); staticBlock.assign(urlField, urlVar); staticBlock.assign(exField, exVar); }
private void writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null()); JTryBlock tryBlock = staticBlock._try(); tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation)); JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class)); JVar murlVar = catchBlock.param("murl"); catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar)); staticBlock.assign(urlField, urlVar); staticBlock.assign(exField, exVar); }
private void writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null()); JTryBlock tryBlock = staticBlock._try(); tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation)); JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class)); JVar murlVar = catchBlock.param("murl"); catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar)); staticBlock.assign(urlField, urlVar); staticBlock.assign(exField, exVar); }
private void writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null()); JTryBlock tryBlock = staticBlock._try(); tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation)); JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class)); JVar murlVar = catchBlock.param("murl"); catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar)); staticBlock.assign(urlField, urlVar); staticBlock.assign(exField, exVar); }