本文整理了Java中com.sun.codemodel.JMethod.type()
方法的一些代码示例,展示了JMethod.type()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMethod.type()
方法的具体详情如下:
包路径:com.sun.codemodel.JMethod
类名称:JMethod
方法名:type
[英]Return type for this method
[中]此方法的返回类型
代码示例来源:origin: joelittlejohn/jsonschema2pojo
private static void processMethodCollectionForSerializableSupport(Iterator
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
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;
}