本文整理汇总了Java中com.github.javaparser.ast.type.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于com.github.javaparser.ast.type包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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")
;
}
示例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())));
}
}
}
}
}
示例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);
}
示例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;
}
示例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 + "].");
}
示例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(">");
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}