• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.javaparser.ast.type.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Type类属于com.github.javaparser.ast.type包,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {

			MethodDVO methodDVO = new MethodDVO();
			methodDVO.setMethodName(n.getName());
			methodDVO.setVisivility(GargoyleJavaParser.toStringVisibility(n.getModifiers()));
			methodDVO.setDescription(n.getComment() != null ? n.getComment().toString() : "");
			ArrayList<MethodParameterDVO> methodParameterDVOList = new ArrayList<>();
			methodDVO.setMethodParameterDVOList(methodParameterDVOList);
			List<Parameter> parameters = n.getParameters();
			for (Parameter p : parameters) {
				//				String string2 = p.toString();
				VariableDeclaratorId id2 = p.getId();
				String varName = id2.getName();
				Type type = p.getType();
				String typeName = type.toString();
				Comment comment = p.getComment();
				methodParameterDVOList.add(new MethodParameterDVO(varName, typeName, "", comment == null ? "" : comment.toString()));
			}

			onMethodDVOVisite.accept(methodDVO);

			super.visit(n, arg);
		}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:24,代码来源:BaseInfoComposite.java


示例2: typeOf

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
@Nullable
Class<?> typeOf( Type type ) {
    if ( type instanceof ReferenceType ) {
        ReferenceType referenceType = ( ReferenceType ) type;
        if ( referenceType.getArrayCount() > 0 ) {
            return Array.class;
        }
        // unwrap the reference type and try again
        return typeOf( referenceType.getType() );
    }

    if ( type instanceof PrimitiveType ) {
        String typeName = ( ( PrimitiveType ) type ).getType().name();
        return primitiveType( typeName );
    } else if ( type instanceof ClassOrInterfaceType ) try {
        return classForName( ( ( ClassOrInterfaceType ) type ).getName() );
    } catch ( ClassNotFoundException e ) {
        // class not found, ignore
    }

    return null;
}
 
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:23,代码来源:TypeDiscoverer.java


示例3: isNumeric

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public boolean isNumeric() {
	Type propertyType = getPropertyType();
	String s = propertyType.asString();
	s = s.substring(0, s.lastIndexOf('.') + 1);
	return s.equals("int")
		|| s.equals("short")
		|| s.equals("byte")
		|| s.equals("long")
		|| s.equals("float")
		|| s.equals("double")
		|| s.equals("BigDecimal")
		|| s.equals("BigInteger")
		|| s.equals("Integer")
		|| s.equals("Short")
		|| s.equals("Byte")
		|| s.equals("Long")
		|| s.equals("Float")
		|| s.equals("Double")
		;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:21,代码来源:ColumnWrapper.java


示例4: visit

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
@Override
public final void visit(ClassOrInterfaceType ctx, Object arg) {

    if (!componentStack.isEmpty()) {
        final Component currCmp = componentStack.peek();
        currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(ctx.asClassOrInterfaceType().getNameAsString())));
        List<Type> typeArguments = new ArrayList<>();
        if (ctx.getTypeArguments().isPresent()) {
            typeArguments.addAll(ctx.getTypeArguments().get());
            for (Type typeArg : typeArguments) {
                if (typeArg.isClassOrInterfaceType()) {
                    if (((ClassOrInterfaceType) typeArg).getTypeArguments().isPresent()) {
                        visit(((ClassOrInterfaceType) typeArg), arg);
                    } else {
                        currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(typeArg.asClassOrInterfaceType().getNameAsString())));
                    }
                } else {
                    currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(typeArg.asString())));
                }
            }
        }
    }
}
 
开发者ID:Zir0-93,项目名称:clarpse,代码行数:24,代码来源:JavaTreeListener.java


示例5: visit

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
@Override
public void visit(FieldDeclaration n, FieldInfos fieldInfos) {
    for (final VariableDeclarator variable : n.getVariables()) {
        Type type = n.getType();
        if (ModifierSet.isPublic(n.getModifiers())) {
            FieldInfo fieldInfo = new FieldInfo(type, variable, n.getComment(), fieldInfos.typeMap);
        /*System.out.println("Type: " + type+ "Type1: " + type.getClass().getName());
        System.out.println("Vars: "+ variable);
        System.out.println("Jdoc: " +n.getComment());
        System.out.println(fieldInfo);
        System.out.println("");*/
            fieldInfos.addField(fieldInfo);
        }
    }

    //super.visit(n, arg);
}
 
开发者ID:buma,项目名称:GraphQlGenerator,代码行数:18,代码来源:ReadClass.java


示例6: isIntrospectionRelevantNode

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
private boolean isIntrospectionRelevantNode(Node node) {
    if (node instanceof Type && node.getParentNode() instanceof MethodDeclaration) {
        return false;
    }

    if (node instanceof Parameter && node.getParentNode() instanceof MethodDeclaration) {
        return false;
    }

    if (!(node instanceof AnnotationExpr) && node.getParentNode() instanceof BaseParameter) {
        return false;
    }

    if (node instanceof NameExpr && node.getParentNode() instanceof AnnotationExpr) {
        return false;
    }

    if (node.getParentNode() instanceof FieldAccessExpr) {
        return false;
    }

    return true;
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:24,代码来源:SpringWebValidatorMojo.java


示例7: apply

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public TypeRef apply(Type type) {
    if (type instanceof VoidType) {
        return new VoidRef();
    } else if (type instanceof WildcardType) {
        return new WildcardRef();
    } else if (type instanceof ReferenceType) {
        ReferenceType referenceType = (ReferenceType) type;
        int dimensions = referenceType.getArrayCount();
        TypeRef typeRef = TYPEREF.apply(referenceType.getType());
        if (dimensions == 0) {
            return typeRef;
        } else if (typeRef instanceof ClassRef) {
            return new ClassRefBuilder((ClassRef)typeRef).withDimensions(dimensions).build();
        } else if (typeRef instanceof PrimitiveRef) {
            return new PrimitiveRefBuilder((PrimitiveRef)typeRef).withDimensions(dimensions).build();
        } else if (typeRef instanceof TypeParamRef) {
            return new TypeParamRefBuilder((TypeParamRef)typeRef).withDimensions(dimensions).build();
        }
    } else if (type instanceof PrimitiveType) {
        PrimitiveType primitiveType = (PrimitiveType) type;
        return new PrimitiveRefBuilder().withName(primitiveType.getType().name()).build();
    } else if (type instanceof ClassOrInterfaceType) {
        return CLASS_OR_TYPEPARAM_REF.apply((ClassOrInterfaceType) type);
    }
    throw new IllegalArgumentException("Can't handle type:[" + type + "].");
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:27,代码来源:Sources.java


示例8: printTypeArgs

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
private void printTypeArgs(final NodeWithTypeArguments<?> nodeWithTypeArguments, final Void arg) {
	NodeList<Type> typeArguments = nodeWithTypeArguments.getTypeArguments().orElse(null);
	if (!isNullOrEmpty(typeArguments)) {
		printer.print("<");
		for (final Iterator<Type> i = typeArguments.iterator(); i.hasNext(); ) {
			final Type t = i.next();
			t.accept(this, arg);
			if (i.hasNext()) {
				printer.print(", ");
			}
		}
		printer.print(">");
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:15,代码来源:SrcRemapper.java


示例9: visit

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
@Override
public void visit(FieldDeclaration n, Object arg) {

	Type type = n.getType();

	if (type instanceof ReferenceType) {
		ReferenceType refType = (ReferenceType) type;
		if (refType.getType() instanceof ClassOrInterfaceType) {
			ClassOrInterfaceType cOrInterfaceType = (ClassOrInterfaceType) refType.getType();
			if (cOrInterfaceType == null)
				return;
			int modifiers = n.getModifiers();
			List<VariableDeclarator> variables = n.getVariables();
			String fieldName = null;
			if (variables != null && variables.size() == 1) {
				fieldName = variables.get(0).toString();
			}

			if (fieldName == null)
				return;

			try {
				FieldMeta fieldMeta = ClassTypeResourceLoader.getInstance().get(cOrInterfaceType.getName());
				fieldMeta.setName(fieldName);
				fieldMeta.setModifier(modifiers);
				fieldMes.add(fieldMeta);
			} catch (ClassNotFoundException e) {
				// Nothing..
			}
		}
	}
	super.visit(n, arg);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:34,代码来源:VOEditorParser2.java


示例10: createListProperty

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public ColumnWrapper createListProperty(ColumnWrapper childsParentProperty) {
	if(getSimpleName().equalsIgnoreCase("EAttribute")) {
		if(childsParentProperty.getClassWrapper().getSimpleName().equalsIgnoreCase("ConfDatamartFact")) {
			System.out.println("GOTCHA");
		}

		System.out.println("GOTCHA");
	}
	ColumnWrapper cw = createColumnWrapper();

	//-- Type is List<T> where T is this-property's type.
	importIf("java.util.List");

	ClassWrapper childClass = childsParentProperty.getClassWrapper();
	ClassOrInterfaceType ct = new ClassOrInterfaceType(childClass.getClassName());
	Type childType = importIf(ct);

	ClassOrInterfaceType lt = new ClassOrInterfaceType(null, new SimpleName("List"), NodeList.nodeList(childType));
	cw.setPropertyType(lt);

	//-- Calculate a simplistic property name provisionally. This step can create duplicate property names.
	String override = childsParentProperty.getConfigProperty("parentName");
	if(null != override) {
		cw.setPropertyName(override);
	} else {
		String childName = childsParentProperty.getClassWrapper().getSimpleName();
		String name = AbstractGenerator.camelCase(childName) + "List";
		cw.setPropertyName(name);
	}
	cw.setOneToMany(childsParentProperty);

	return cw;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:34,代码来源:ClassWrapper.java


示例11: getArr

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
/**
 * Build descriptor array level.
 * 
 * @param type
 * @return
 */
private String getArr(Type type) {
	String arr = "";
	for (int k = 0; k < type.getArrayLevel(); k++) {
		arr += "[";
	}
	return arr;
}
 
开发者ID:Col-E,项目名称:JRemapper,代码行数:14,代码来源:Context.java


示例12: parseTryStatement

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
/**
 *
 * @param ts
 *      a github javaparser TryStatement
 * @param attributes
 *      the list of attributes of the class,
 *      to potentially get a type from the name
 * @param bd
 *      a body declaration
 * @return
 *      a TryStatement structure
 */
private TryStatement parseTryStatement(TryStmt ts, List<Attribute> attributes, BodyDeclaration bd) {
    TryStatement tryStatement = new TryStatement();
    tryStatement.setBody(parseStatement(ts.getTryBlock(), attributes, bd));
    if (ts.getCatchs() != null) {
        List<CatchClause> catchClauses = new ArrayList<>();
        List<com.github.javaparser.ast.stmt.CatchClause> japaCatchClauses = ts.getCatchs();
        for (com.github.javaparser.ast.stmt.CatchClause japaCatchClause : japaCatchClauses) {
            CatchClause catchClause = new CatchClause();
            List<Field> params = new ArrayList<>();
            if (japaCatchClause.getExcept().getTypes() != null) {
                for (Type t : japaCatchClause.getExcept().getTypes()) {
                    String type = ParserUtils.parseException(t.toString()).get("type");
                    String name = ParserUtils.parseException(t.toString()).get("name");
                    List<String> doc = null;
                    if (t.getComment() != null) {
                        doc = ParserUtils.prepareComments(t.getComment().getContent());
                    }
                    Field f = new Field(doc, name, type);
                    params.add(f);
                }
            }
            catchClause.setParameters(params);
            List<Stmt> body = new ArrayList<>();
            body.addAll(parseStatement(japaCatchClause.getCatchBlock(), attributes, bd));
            catchClause.setBody(body);
            catchClauses.add(catchClause);
            this.loc++;
        }
        tryStatement.setCatchClauses(catchClauses);
    }
    if (ts.getFinallyBlock() != null) {
        tryStatement.setFinallyStmts(parseStatement(ts.getFinallyBlock(), attributes, bd));
    }

    return tryStatement;
}
 
开发者ID:DevMine,项目名称:parsers,代码行数:49,代码来源:Parser.java


示例13: CatchClause

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
	    final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final Type exceptTypes,
	    final VariableDeclaratorId exceptId, final BlockStmt catchBlock) {
    super(beginLine, beginColumn, endLine, endColumn);
    setParam(new Parameter(beginLine, beginColumn, endLine, endColumn, exceptModifier, exceptAnnotations, exceptTypes, false, exceptId));
    setCatchBlock(catchBlock);
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:8,代码来源:CatchClause.java


示例14: setType

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
@Override
public Parameter setType(Type type) {
    Pair<Type, List<ArrayBracketPair>> unwrapped = ArrayType.unwrapArrayTypes(type);
    setElementType(unwrapped.a);
    setArrayBracketPairsAfterElementType(unwrapped.b);
    getId().setArrayBracketPairsAfterId(null);
    return this;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:9,代码来源:Parameter.java


示例15: FieldDeclaration

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public FieldDeclaration(int modifiers, Type type, VariableDeclarator variable) {
	setModifiers(modifiers);
	setType(type);
	List<VariableDeclarator> aux = new ArrayList<VariableDeclarator>();
	aux.add(variable);
	setVariables(aux);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:8,代码来源:FieldDeclaration.java


示例16: AxiomDeclaration

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public AxiomDeclaration(final int modifiers, final Type type, final String name,
		    final List<AxiomParameter> parameters) {
setModifiers(modifiers);
setType(type);
setName(name);
setParameters(parameters);
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:8,代码来源:AxiomDeclaration.java


示例17: VariableDeclarationExpr

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public VariableDeclarationExpr(final Range range,
                               final EnumSet<Modifier> modifiers, final List<AnnotationExpr> annotations,
                               final Type elementType,
                               final List<VariableDeclarator> variables,
                               final List<ArrayBracketPair> arrayBracketPairsAfterType) {
    super(range);
    setModifiers(modifiers);
    setAnnotations(annotations);
    setElementType(elementType);
    setVariables(variables);
    setArrayBracketPairsAfterElementType(arrayBracketPairsAfterType);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:13,代码来源:VariableDeclarationExpr.java


示例18: ObjectCreationExpr

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public ObjectCreationExpr(final Range range,
		final Expression scope, final ClassOrInterfaceType type, final List<Type<?>> typeArguments,
                             final List<Expression> args, final List<BodyDeclaration<?>> anonymousBody) {
	super(range);
	setScope(scope);
	setType(type);
	setTypeArguments(typeArguments);
	setArgs(args);
	setAnonymousClassBody(anonymousBody);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:11,代码来源:ObjectCreationExpr.java


示例19: MethodDeclaration

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public MethodDeclaration(final EnumSet<Modifier> modifiers, final Type elementType, final String name,
                         final List<Parameter> parameters) {
    setModifiers(modifiers);
    setElementType(elementType);
    setName(name);
    setParameters(parameters);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:8,代码来源:MethodDeclaration.java


示例20: MethodDeclaration

import com.github.javaparser.ast.type.Type; //导入依赖的package包/类
public MethodDeclaration(final int modifiers, final List<AnnotationExpr> annotations,
			 final List<TypeParameter> typeParameters, final Type type, final String name,
			 final List<Parameter> parameters, final int arrayCount,
			 final List<ReferenceType> throws_, final BlockStmt block) {
	super(annotations);
	setModifiers(modifiers);
	setTypeParameters(typeParameters);
	setType(type);
	setName(name);
	setParameters(parameters);
	setArrayCount(arrayCount);
	setThrows(throws_);
	setBody(block);
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:15,代码来源:MethodDeclaration.java



注:本文中的com.github.javaparser.ast.type.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultCommentGenerator类代码示例发布时间:2022-05-21
下一篇:
Java PaginationService类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap