当前位置: 首页>>代码示例>>Java>>正文


Java ExecutableElement.getReturnType方法代码示例

本文整理汇总了Java中javax.lang.model.element.ExecutableElement.getReturnType方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableElement.getReturnType方法的具体用法?Java ExecutableElement.getReturnType怎么用?Java ExecutableElement.getReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.element.ExecutableElement的用法示例。


在下文中一共展示了ExecutableElement.getReturnType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSetter

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected boolean isSetter(TypeElement element, ExecutableElement x, boolean includeStatic) {
    final String name = x.getSimpleName().toString();
    final TypeMirror returnType = x.getReturnType();
    final boolean isStatic = includeStatic && x.getParameters().size() == 2;

    if (x.getParameters().size() != (isStatic ? 2 : 1)) {
        return false;
    }
    if (isStatic && !types().isSameType(x.getParameters().get(0).asType(), element.asType())) {
        return false;
    }
    if (!name.startsWith("set")) {
        return false;
    }
    if (returnType.getKind().equals(TypeKind.VOID)) {
        return true;
    }
    return x.getEnclosingElement() != null && types().isAssignable(x.getEnclosingElement().asType(), returnType);
}
 
开发者ID:intendia-oss,项目名称:qualifier,代码行数:20,代码来源:TypeHelper.java

示例2: replaceReturnType

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Override
public TypeName replaceReturnType(String currentPkg, String directParentInterface, String curClassname,
                                  List<? extends TypeMirror> superInterfaces, TypeName superClass, ExecutableElement method) {
    final TypeMirror returnType = method.getReturnType();
    switch (method.getSimpleName().toString()){
        case TypeCopyableFiller.NAME_COPY: {
            switch (returnType.getKind()) {
                case TYPEVAR: //泛型
                    return  TypeVariableName.get(directParentInterface);

                default:
                    return TypeName.get(returnType);
            }
        }

        default:
            return TypeName.get(returnType);

    }

}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:22,代码来源:CopyReplacer.java

示例3: processGetters

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private void processGetters() {
    // Check presence !
    TypeMirror listType = compilationInfo.getElements().getTypeElement(LIST_CLASS).asType();
    TypeMirror mapType = compilationInfo.getElements().getTypeElement(MAP_CLASS).asType();
    for (ExecutableElement m : getters) {
        String n = getPropertyName(m.getSimpleName().toString());
        if (allProperties.containsKey(n)) {
            continue;
        }
        TypeMirror retType = m.getReturnType();
        TypeMirror erasure = compilationInfo.getTypes().erasure(retType);
        if (compilationInfo.getTypes().isAssignable(erasure, listType)) {
            addListProperty(m, n);
        } else if (compilationInfo.getTypes().isAssignable(erasure, mapType)) {
            addMapProperty(m, n);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:BeanModelBuilder.java

示例4: setExecutableElement

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
void setExecutableElement(ExecutableElement executableElement) {
    this.executableElement = executableElement;
    StringBuilder nameBuilder = new StringBuilder();
    nameBuilder.append(BOLD);
    nameBuilder.append(htmlName);
    nameBuilder.append(BOLD_END);
    nameBuilder.append('(');
    List<? extends VariableElement> parameters = executableElement.getParameters();
    //List<? extends TypeParameterElement> typeParameters = executableElement.getTypeParameters();
    int n = parameters.size();
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            nameBuilder.append(", ");
        }
        //nameBuilder.append(escape(typeParameters.get(i).getSimpleName().toString()));
        nameBuilder.append(escape(getTypeSimpleName(parameters.get(i).asType())));
        nameBuilder.append(' ');
        nameBuilder.append(PARAMETER_NAME_COLOR);
        nameBuilder.append(parameters.get(i).getSimpleName());
        nameBuilder.append("</font>");
    }
    nameBuilder.append(')');
    htmlName = nameBuilder.toString();
    TypeMirror returnType = executableElement.getReturnType();
    rightHtmlName = getTypeSimpleName(returnType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ElementCompletionItem.java

示例5: TimedMethodModel

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
TimedMethodModel(ModelContext ctx, ExecutableElement method, TimeThis annotation) throws ModelException {
	this.annotation = annotation;
	this.method = method;
	this.scope = getScope(method);
	String msg = "method " + method.getSimpleName() + " in " + method.getEnclosingElement();
	List<? extends VariableElement> params = method.getParameters();
	if (params.isEmpty()) {
		throw new ModelException(msg + ": expected at least one " + ProcessingContext.class.getCanonicalName() + " parameter");
	}
	boolean first = true;
	for (VariableElement param : params) {
		TypeMirror paramType = param.asType();
		if (first) {
			if (!ctx.isProcessingContext(paramType)) {
				throw new ModelException(msg + ": first parameter must be of type " + ProcessingContext.class.getCanonicalName());
			}
			first = false;
			continue;
		}
		checkPublicType(ctx, paramType, method, false, msg);
	}
	TypeMirror returnType = method.getReturnType();
	checkPublicType(ctx, returnType, method, true, msg);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:25,代码来源:TimedMethodModel.java

示例6: setComponentTypeName

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private void setComponentTypeName( @Nonnull final ExecutableElement componentTypeName )
  throws ArezProcessorException
{
  MethodChecks.mustBeOverridable( Constants.COMPONENT_TYPE_NAME_REF_ANNOTATION_CLASSNAME, componentTypeName );
  MethodChecks.mustNotHaveAnyParameters( Constants.COMPONENT_TYPE_NAME_REF_ANNOTATION_CLASSNAME, componentTypeName );
  MethodChecks.mustReturnAValue( Constants.COMPONENT_TYPE_NAME_REF_ANNOTATION_CLASSNAME, componentTypeName );
  MethodChecks.mustNotThrowAnyExceptions( Constants.COMPONENT_TYPE_NAME_REF_ANNOTATION_CLASSNAME, componentTypeName );

  final TypeMirror returnType = componentTypeName.getReturnType();
  if ( !( TypeKind.DECLARED == returnType.getKind() &&
          returnType.toString().equals( String.class.getName() ) ) )
  {
    throw new ArezProcessorException( "@ComponentTypeNameRef target must return a String", componentTypeName );
  }

  if ( null != _componentTypeName )
  {
    throw new ArezProcessorException( "@ComponentTypeNameRef target duplicates existing method named " +
                                      _componentTypeName.getSimpleName(), componentTypeName );
  }
  else
  {
    _componentTypeName = Objects.requireNonNull( componentTypeName );
  }
}
 
开发者ID:arez,项目名称:arez,代码行数:26,代码来源:ComponentDescriptor.java

示例7: validateStaticVoid

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static void validateStaticVoid(ExecutableElement executableElement, Class<?> clazz) {
  if (!executableElement.getModifiers().contains(Modifier.STATIC)) {
    throw new IllegalArgumentException("@" + clazz.getSimpleName() + " methods must be static");
  }
  TypeMirror returnType = executableElement.getReturnType();
  if (returnType.getKind() != TypeKind.VOID) {
    throw new IllegalArgumentException("@" + clazz.getSimpleName() + " methods must return void");
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:GlideExtensionValidator.java

示例8: addMapProperty

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private void addMapProperty(ExecutableElement m, String propName) {
    FxProperty pi = new FxProperty(propName, FxDefinitionKind.MAP);
    pi.setSimple(false);
    pi.setAccessor(ElementHandle.create(m));
    
    // must extract type arguments; assume there's a DeclaredType
    DeclaredType t = ((DeclaredType)m.getReturnType());
    ExecutableType getterType = findMapGetMethod(t);
    
    pi.setType(TypeMirrorHandle.create(getterType.getReturnType()));
    pi.setObservableAccessors(pi.getAccessor());
    
    registerProperty(pi);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:BeanModelBuilder.java

示例9: createHtmlHeader

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static String createHtmlHeader(boolean deprecated, ExecutableElement e) {
    StringBuilder sb = new StringBuilder();
    sb.append("<html>");
    if (deprecated) sb.append("<s>");
    if (e.getKind() == ElementKind.CONSTRUCTOR) {
        sb.append(e.getEnclosingElement().getSimpleName());
    } else {
        sb.append(e.getSimpleName());
    }
    if (deprecated) sb.append("</s>");
    sb.append("("); // NOI18N
    for(Iterator<? extends VariableElement> it = e.getParameters().iterator(); it.hasNext(); ) {
        VariableElement param = it.next();
        if (!it.hasNext() && e.isVarArgs() && param.asType().getKind() == TypeKind.ARRAY) {
            sb.append(translateToHTML(print(((ArrayType) param.asType()).getComponentType())));
            sb.append("...");
        } else {
            sb.append(translateToHTML(print(param.asType())));
        }
        sb.append(" "); // NOI18N
        sb.append(param.getSimpleName());
        if (it.hasNext()) {
            sb.append(", "); // NOI18N
        }
    }
    sb.append(")"); // NOI18N
    if ( e.getKind() != ElementKind.CONSTRUCTOR ) {
        TypeMirror rt = e.getReturnType();
        if ( rt.getKind() != TypeKind.VOID ) {
            sb.append(" : "); // NOI18N
            sb.append(translateToHTML(print(e.getReturnType())));
        }
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ElementNode.java

示例10: Property

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public Property(Types typeUtils, ExecutableElement element, String name) {
    this.element = element;
    this.name = name;
    this.type = element.getReturnType().toString();
    if (element.getReturnType().getKind().isPrimitive()) {
        PrimitiveType primitiveType = (PrimitiveType) element.getReturnType();
        this.nonPrimitiveType = typeUtils.boxedClass(primitiveType).toString();
        this.primitive = true;
    } else {
        this.nonPrimitiveType = element.getReturnType().toString();
    }
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:13,代码来源:Generator.java

示例11: getParameterizedReturn

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public TypeName getParameterizedReturn(Element method){
    if(method.getKind() == METHOD) {
        ExecutableElement executableElement = (ExecutableElement) method;
        final TypeMirror returnType = executableElement.getReturnType();

        try {
            return ((ParameterizedTypeName) ParameterizedTypeName.get(returnType)).typeArguments.get(0);
        } catch (Exception e){
            return TypeName.get(returnType);
        }

    }
    return null;
}
 
开发者ID:florent37,项目名称:Rx.Observe,代码行数:15,代码来源:ProcessUtils.java

示例12: applicable

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Override
public boolean applicable(Context context) {
    TypeElement type = context.autoValueClass();

    for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) {
        TypeMirror rType = method.getReturnType();
        TypeName returnType = TypeName.get(rType);

        if (returnType.toString().equals("Node_" + type.getSimpleName())) {
            return true;
        }
    }

    return false;
}
 
开发者ID:ccheptea,项目名称:auto-value-node,代码行数:16,代码来源:AutoValueNodeExtension.java

示例13: isGetter

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected boolean isGetter(TypeElement element, ExecutableElement x, boolean includeStatic) {
    final String name = x.getSimpleName().toString();
    final TypeMirror returnType = x.getReturnType();
    final boolean isStatic = includeStatic && x.getParameters().size() == 1;

    if (x.getParameters().size() != (isStatic ? 1 : 0)) {
        return false;
    }
    if (isStatic && !types().isSameType(x.getParameters().get(0).asType(), element.asType())) {
        return false;
    }
    if (name.startsWith("get")) {
        return true;
    }
    if (name.startsWith("is") || name.startsWith("has")) {
        if (returnType.getKind().equals(TypeKind.BOOLEAN)) {
            return true;
        }
    }
    if (name.startsWith("is") || name.startsWith("has")) {
        TypeMirror javaLangBoolean = types().boxedClass(types().getPrimitiveType(TypeKind.BOOLEAN)).asType();
        if (returnType.getKind().equals(TypeKind.BOOLEAN) || types().isSameType(returnType, javaLangBoolean)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:intendia-oss,项目名称:qualifier,代码行数:28,代码来源:TypeHelper.java

示例14: isGetter

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public static boolean isGetter(ExecutableElement ee) {
    String methodName = ee.getSimpleName().toString();
    TypeMirror retType = ee.getReturnType();

    // discard private and static methods
    if (ee.getModifiers().contains(Modifier.PRIVATE) || ee.getModifiers().contains(Modifier.STATIC)) {
        return false;
    }
    
    
    boolean retVal = methodName.startsWith(GET_PREFIX) && methodName.length() > GET_PREFIX.length() && retType.getKind() != TypeKind.VOID;
    retVal = retVal || methodName.startsWith(IS_PREFIX) && methodName.length() > IS_PREFIX.length() && retType.getKind() == TypeKind.BOOLEAN;
    
    return retVal;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:JavaUtils.java

示例15: isSetter

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public static boolean isSetter(ExecutableElement ee) {
    String methodName = ee.getSimpleName().toString();
    TypeMirror retType = ee.getReturnType();
    
    // discard private and static methods
    if (ee.getModifiers().contains(Modifier.PRIVATE) || ee.getModifiers().contains(Modifier.STATIC)) {
        return false;
    }
    
    return methodName.startsWith(SET_PREFIX) && methodName.length() > SET_PREFIX.length() 
            && retType.getKind() == TypeKind.VOID && ee.getParameters().size() == 1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaUtils.java


注:本文中的javax.lang.model.element.ExecutableElement.getReturnType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。