热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.sun.codemodel.JMethod.type()方法的使用及代码示例

本文整理了Java中com.sun.codemodel.JMethod.type()方法的一些代码示例,展示了JMethod.type()的具

本文整理了Java中com.sun.codemodel.JMethod.type()方法的一些代码示例,展示了JMethod.type()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMethod.type()方法的具体详情如下:
包路径:com.sun.codemodel.JMethod
类名称:JMethod
方法名:type

JMethod.type介绍

[英]Return type for this method
[中]此方法的返回类型

代码示例

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private static void processMethodCollectionForSerializableSupport(Iterator methods, DataOutputStream dataOutputStream) throws IOException {
TreeMap sortedMethods = new TreeMap<>();
while (methods.hasNext()) {
JMethod method = methods.next();
//Collect non-private methods
if ((method.mods().getValue() & JMod.PRIVATE) != JMod.PRIVATE) {
sortedMethods.put(method.name(), method);
}
}
for (JMethod method : sortedMethods.values()) {
dataOutputStream.writeUTF(method.name());
dataOutputStream.writeInt(method.mods().getValue());
if (method.type() != null) {
dataOutputStream.writeUTF(method.type().fullName());
}
for (JVar param : method.params()) {
dataOutputStream.writeUTF(param.type().fullName());
}
}
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicSetMethod(JDefinedClass jclass, JMethod internalSetMethod) {
JMethod method = jclass.method(PUBLIC, jclass.owner().VOID, SETTER_NAME);
JVar nameParam = method.param(String.class, "name");
JVar valueParam = method.param(Object.class, "value");
JBlock body = method.body();
JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();
// if we have additional properties, then put value.
JMethod getAdditiOnalProperties= jclass.getMethod("getAdditionalProperties", new JType[] {});
if (getAdditionalProperties != null) {
JType additiOnalPropertiesType= ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
.arg(cast(additionalPropertiesType, valueParam)));
}
// else throw exception.
else {
notFound._throw(illegalArgumentInvocation(jclass, nameParam));
}
return method;
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicWithMethod(JDefinedClass jclass, JMethod internalSetMethod) {
JMethod method = jclass.method(PUBLIC, jclass, BUILDER_NAME);
JVar nameParam = method.param(String.class, "name");
JVar valueParam = method.param(Object.class, "value");
JBlock body = method.body();
JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();
// if we have additional properties, then put value.
JMethod getAdditiOnalProperties= jclass.getMethod("getAdditionalProperties", new JType[] {});
if (getAdditionalProperties != null) {
JType additiOnalPropertiesType= ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
.arg(cast(additionalPropertiesType, valueParam)));
}
// else throw exception.
else {
notFound._throw(illegalArgumentInvocation(jclass, nameParam));
}
body._return(_this());
return method;
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicGetMethod(JDefinedClass jclass, JMethod internalGetMethod, JFieldRef notFoundValue) {
JMethod method = jclass.method(PUBLIC, jclass.owner()._ref(Object.class), GETTER_NAME);
JTypeVar returnType = method.generify("T");
method.type(returnType);
Models.suppressWarnings(method, "unchecked");
JVar nameParam = method.param(String.class, "name");
JBlock body = method.body();
JVar valueVar = body.decl(jclass.owner()._ref(Object.class), "value",
invoke(internalGetMethod).arg(nameParam).arg(notFoundValue));
JConditional found = method.body()._if(notFoundValue.ne(valueVar));
found._then()._return(cast(returnType, valueVar));
JBlock notFound = found._else();
JMethod getAdditiOnalProperties= jclass.getMethod("getAdditionalProperties", new JType[] {});
if (getAdditionalProperties != null) {
notFound._return(cast(returnType, invoke(getAdditionalProperties).invoke("get").arg(nameParam)));
} else {
notFound._throw(illegalArgumentInvocation(jclass, nameParam));
}
return method;
}

代码示例来源:origin: stackoverflow.com

final JDefinedClass exampleClass = codeModel._class( "com.example.ExampleClass" );
final JMethod method = exampleClass.method( JMod.PUBLIC, Object.class, "getValue" );
final JTypeVar t = method.generify( "T" );
method.type( t );
method.param( codeModel.ref( Class.class ).narrow( t ), "type" );
method.body()._return(JExpr._null());

代码示例来源:origin: krasa/krasa-jaxb-tools

private void setReturnType(JType type, JMethod jMethod) {
if (jMethod != null) {
jMethod.type(type);
}
}

代码示例来源:origin: mklemm/jaxb2-rich-contract-plugin

private void generateBuilderMethodJavadoc(final JMethod method, final String methodPrefix, final String propertyName) {
final String endMethodClassName = method.type().erasure().fullName();
method.javadoc().append(MessageFormat.format(this.resources.getString("comment." + methodPrefix + "BuilderMethod"), propertyName, endMethodClassName))
.addReturn().append(MessageFormat.format(this.resources.getString("comment." + methodPrefix + "BuilderMethod.return"), propertyName, endMethodClassName));
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

public boolean isFieldOutlineCore(Mapping context, FieldOutline fieldOutline) {
final JMethod getter = FieldAccessorUtils.getter(fieldOutline);
final JType type = getter.type();
return JTypeUtils.isBasicType(type);
}

代码示例来源:origin: highsource/hyperjaxb3

public boolean isFieldOutlineCore(Mapping context, FieldOutline fieldOutline) {
final JMethod getter = FieldAccessorUtils.getter(fieldOutline);
final JType type = getter.type();
return JTypeUtils.isBasicType(type);
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

public boolean isFieldOutlineCore(Mapping context, FieldOutline fieldOutline) {
final JMethod getter = FieldAccessorUtils.getter(fieldOutline);
final JType type = getter.type();
return JTypeUtils.isBasicType(type);
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

public boolean isTemporal(Mapping context, FieldOutline fieldOutline) {
final JMethod getter = FieldAccessorUtils.getter(fieldOutline);
final JType type = getter.type();
return JTypeUtils.isTemporalType(type);
}

代码示例来源:origin: Evolveum/midpoint

private JMethod createReferenceFluentEnd(ClassOutline classOutline) {
String methodName = "end";
JMethod method = classOutline.implClass.method(JMod.PUBLIC, (JType) null, methodName);
method.type(method.generify("X"));
JBlock body = method.body();
body._return(JExpr.cast(method.type(),
JExpr.invoke(JExpr.cast(CLASS_MAP.get(PrismContainerValue.class),
JExpr.invoke(JExpr.cast(CLASS_MAP.get(PrismReference.class),
JExpr.invoke(JExpr.invoke("asReferenceValue"),"getParent")), "getParent")),
"asContainerable")));
return method;
}

代码示例来源:origin: Evolveum/midpoint

private JMethod createContainerFluentEnd(ClassOutline classOutline) {
String methodName = "end";
JMethod method = classOutline.implClass.method(JMod.PUBLIC, (JType) null, methodName);
method.type(method.generify("X"));
JBlock body = method.body();
body._return(JExpr.cast(method.type(),
JExpr.invoke(JExpr.cast(CLASS_MAP.get(PrismContainerValue.class),
JExpr.invoke(JExpr.cast(CLASS_MAP.get(PrismContainer.class),
JExpr.invoke(JExpr.invoke("asPrismContainerValue"),"getParent")), "getParent")),
"asContainerable")));
return method;
}

代码示例来源:origin: org.jvnet.jaxb2_commons/tools

public static JMethod setter(FieldOutline fieldOutline) {
final JMethod getter = getter(fieldOutline);
assert getter != null : "Getter is required.";
final JType type = getter.type();
final JDefinedClass theClass = fieldOutline.parent().implClass;
final String publicName = fieldOutline.getPropertyInfo().getName(true);
final String name = "set" + publicName;
return theClass.getMethod(name, new JType[] { type });
}

代码示例来源:origin: org.andromda.thirdparty.jaxb2_commons/tools

public static JMethod setter(FieldOutline fieldOutline) {
final JMethod getter = getter(fieldOutline);
assert getter != null : "Getter is required.";
final JType type = getter.type();
final JDefinedClass theClass = fieldOutline.parent().implClass;
final String publicName = fieldOutline.getPropertyInfo().getName(true);
final String name = "set" + publicName;
return theClass.getMethod(name, new JType[] { type });
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-tools

public static JMethod setter(FieldOutline fieldOutline) {
final JMethod getter = getter(fieldOutline);
assert getter != null : "Getter is required.";
final JType type = getter.type();
final JDefinedClass theClass = fieldOutline.parent().implClass;
final String publicName = fieldOutline.getPropertyInfo().getName(true);
final String name = "set" + publicName;
return theClass.getMethod(name, new JType[] { type });
}

代码示例来源:origin: com.googlecode.androidannotations/androidannotations

public void callSuperMethod(JMethod superMethod, EBeanHolder holder, JBlock callBlock) {
JExpression activitySuper = holder.generatedClass.staticRef("super");
JInvocation superCall = JExpr.invoke(activitySuper, superMethod);
for (JVar param : superMethod.params()) {
superCall.arg(param);
}
JType returnType = superMethod.type();
if (returnType.fullName().equals("void")) {
callBlock.add(superCall);
} else {
callBlock._return(superCall);
}
}

代码示例来源:origin: stackoverflow.com

private JMethod makeHeadersWrapper( String endPointName, List headersList ) {
JClass headerClass = codeModel.ref( headersList.getClass() ).narrow( BasicNameValuePair.class );
JMethod wrapperMethod = definedClass.method( JMod.PUBLIC | JMod.STATIC, headerClass, ( "make" + endPointName + "Header") );
JVar headersListVar = wrapperMethod.body().decl( wrapperMethod.type(), "headersList", JExpr._new(headerClass) );
for(BasicNameValuePair nameValuePair : headersList) {
wrapperMethod.body().add(headersListVar.invoke("add").arg(JExpr._new(nameValuePairClass).arg(nameValuePair.getName()).arg(nameValuePair.getValue())));
}
wrapperMethod.body()._return( headersListVar );
return wrapperMethod;
}

代码示例来源:origin: Evolveum/midpoint

private void createReferenceStringVersionOidType(JFieldVar field, ClassOutline classOutline, JMethod originalMethod, JType objectReferenceType) {
JMethod newMethod = classOutline.implClass.method(JMod.PUBLIC, originalMethod.type(), originalMethod.name());
JVar oid = newMethod.param(String.class, "oid");
JVar type = newMethod.param(QName.class, "type");
JBlock body = newMethod.body();
JVar refVal = body.decl(CLASS_MAP.get(PrismReferenceValue.class), "refVal",
JExpr._new(CLASS_MAP.get(PrismReferenceValueImpl.class))
.arg(oid).arg(type));
JVar ort = body.decl(objectReferenceType, "ort", JExpr._new(objectReferenceType));
body.invoke(ort, METHOD_SETUP_REFERENCE_VALUE).arg(refVal);
body._return(JExpr.invoke(originalMethod).arg(ort));
}

代码示例来源:origin: com.googlecode.androidannotations/androidannotations

private void generateCastMethod(JCodeModel codeModel, EBeanHolder holder) {
JType objectType = codeModel._ref(Object.class);
JMethod method = holder.generatedClass.method(JMod.PRIVATE, objectType, "cast_");
JTypeVar genericType = method.generify("T");
method.type(genericType);
JVar objectParam = method.param(objectType, "object");
method.annotate(SuppressWarnings.class).param("value", "unchecked");
method.body()._return(JExpr.cast(genericType, objectParam));
holder.cast = method;
}

推荐阅读
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 使用在线工具jsonschema2pojo根据json生成java对象
    本文介绍了使用在线工具jsonschema2pojo根据json生成java对象的方法。通过该工具,用户只需将json字符串复制到输入框中,即可自动将其转换成java对象。该工具还能解析列表式的json数据,并将嵌套在内层的对象也解析出来。本文以请求github的api为例,展示了使用该工具的步骤和效果。 ... [详细]
  • 关于我们EMQ是一家全球领先的开源物联网基础设施软件供应商,服务新产业周期的IoT&5G、边缘计算与云计算市场,交付全球领先的开源物联网消息服务器和流处理数据 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • GreenDAO快速入门
    前言之前在自己做项目的时候,用到了GreenDAO数据库,其实对于数据库辅助工具库从OrmLite,到litePal再到GreenDAO,总是在不停的切换,但是没有真正去了解他们的 ... [详细]
  • 本文整理了Java中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
  • 深入理解Kafka服务端请求队列中请求的处理
    本文深入分析了Kafka服务端请求队列中请求的处理过程,详细介绍了请求的封装和放入请求队列的过程,以及处理请求的线程池的创建和容量设置。通过场景分析、图示说明和源码分析,帮助读者更好地理解Kafka服务端的工作原理。 ... [详细]
  • 树莓派语音控制的配置方法和步骤
    本文介绍了在树莓派上实现语音控制的配置方法和步骤。首先感谢博主Eoman的帮助,文章参考了他的内容。树莓派的配置需要通过sudo raspi-config进行,然后使用Eoman的控制方法,即安装wiringPi库并编写控制引脚的脚本。具体的安装步骤和脚本编写方法在文章中详细介绍。 ... [详细]
  • 本文讨论了如何使用Web.Config进行自定义配置节的配置转换。作者提到,他将msbuild设置为详细模式,但转换却忽略了带有替换转换的自定义部分的存在。 ... [详细]
  • VueCLI多页分目录打包的步骤记录
    本文介绍了使用VueCLI进行多页分目录打包的步骤,包括页面目录结构、安装依赖、获取Vue CLI需要的多页对象等内容。同时还提供了自定义不同模块页面标题的方法。 ... [详细]
  • GPT-3发布,动动手指就能自动生成代码的神器来了!
    近日,OpenAI发布了最新的NLP模型GPT-3,该模型在GitHub趋势榜上名列前茅。GPT-3使用的数据集容量达到45TB,参数个数高达1750亿,训练好的模型需要700G的硬盘空间来存储。一位开发者根据GPT-3模型上线了一个名为debuid的网站,用户只需用英语描述需求,前端代码就能自动生成。这个神奇的功能让许多程序员感到惊讶。去年,OpenAI在与世界冠军OG战队的表演赛中展示了他们的强化学习模型,在限定条件下以2:0完胜人类冠军。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
author-avatar
阳光下微醺的我
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有