Java源码示例:japa.parser.ast.type.WildcardType

示例1
@Override
public JType visit(WildcardType type, JCodeModel codeModel) {

	if (type.getExtends() != null) {
		final ReferenceType _extends = type.getExtends();
		final JType boundType = _extends.accept(this, codeModel);

		if (!(boundType instanceof JClass)) {
			throw new IllegalArgumentException("Bound type [" + _extends
					+ "]in the wildcard type must be class.");
		}

		final JClass boundClass = (JClass) boundType;
		return boundClass.wildcard();
	} else if (type.getSuper() != null) {
		// TODO
		throw new IllegalArgumentException(
				"Wildcard types with super clause are not supported at the moment.");
	} else {
		throw new IllegalArgumentException(
				"Wildcard type must have either extends or super clause.");
	}
}
 
示例2
@Override public Boolean visit(final WildcardType n1, final Node arg) {
	final WildcardType n2 = (WildcardType) arg;

	if (!nodeEquals(n1.getExtends(), n2.getExtends())) {
		return Boolean.FALSE;
	}

	if (!nodeEquals(n1.getSuper(), n2.getSuper())) {
		return Boolean.FALSE;
	}

	return Boolean.TRUE;
}
 
示例3
@Override
public Node visit(WildcardType _n, Object _arg) {
	ReferenceType ext = cloneNodes(_n.getExtends(), _arg);
	ReferenceType sup = cloneNodes(_n.getSuper(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	WildcardType r = new WildcardType(
			_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
			ext, sup
	);
	r.setComment(comment);
	return r;
}
 
示例4
@Override public void visit(final WildcardType n, final Object arg) {
	printJavaComment(n.getComment(), arg);
	printer.print("?");
	if (n.getExtends() != null) {
		printer.print(" extends ");
		n.getExtends().accept(this, arg);
	}
	if (n.getSuper() != null) {
		printer.print(" super ");
		n.getSuper().accept(this, arg);
	}
}
 
示例5
@Override public void visit(final WildcardType n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getExtends() != null) {
		n.getExtends().accept(this, arg);
	}
	if (n.getSuper() != null) {
		n.getSuper().accept(this, arg);
	}
}
 
示例6
@Override public Node visit(final WildcardType n, final A arg) {
	if (n.getExtends() != null) {
		n.setExtends((ReferenceType) n.getExtends().accept(this, arg));
	}
	if (n.getSuper() != null) {
		n.setSuper((ReferenceType) n.getSuper().accept(this, arg));
	}
	return n;
}
 
示例7
@Override
public void visitPre(WildcardType n, A arg) {
    
}
 
示例8
@Override
public void visitPost(WildcardType n, A arg) {
    
}
 
示例9
public R visit(WildcardType n, A arg); 
示例10
void visit(WildcardType n, A arg); 
示例11
void visitPre(WildcardType n, A arg); 
示例12
void visitPost(WildcardType n, A arg);