您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

WildcardedUnresolvedType.java 2.1KB

14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
14 年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* *******************************************************************
  2. * Copyright (c) 2008 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Andy Clement initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. /**
  14. * Represents a wildcarded bound for a generic type, this can be unbounded '?' or bounded via extends '? extends Foo' or super '?
  15. * super Foo'. The signature for a ? is in fact "*" and the erasure signature is the upper bound which defaults to java.lang.Object
  16. * if nothing is specified. On resolution, this becomes a BoundedReferenceType
  17. *
  18. * @author Andy Clement
  19. */
  20. public class WildcardedUnresolvedType extends UnresolvedType {
  21. // TODO does not cope with extra bounds '? extends A & B & C'
  22. public static final int UNBOUND = 0;
  23. public static final int EXTENDS = 1;
  24. public static final int SUPER = 2;
  25. public static final WildcardedUnresolvedType QUESTIONMARK = new WildcardedUnresolvedType("*", UnresolvedType.OBJECT, null);
  26. private int boundKind = UNBOUND; // UNBOUND, EXTENDS, SUPER
  27. private UnresolvedType lowerBound;
  28. private UnresolvedType upperBound;
  29. public WildcardedUnresolvedType(String signature, UnresolvedType upperBound, UnresolvedType lowerBound) {
  30. super(signature, (upperBound == null ? UnresolvedType.OBJECT.signature : upperBound.signatureErasure));
  31. this.typeKind = TypeKind.WILDCARD;
  32. this.upperBound = upperBound;
  33. this.lowerBound = lowerBound;
  34. if (signature.charAt(0) == '-') {
  35. boundKind = SUPER;
  36. }
  37. if (signature.charAt(0) == '+') {
  38. boundKind = EXTENDS;
  39. }
  40. }
  41. public UnresolvedType getUpperBound() {
  42. return upperBound;
  43. }
  44. public UnresolvedType getLowerBound() {
  45. return lowerBound;
  46. }
  47. public boolean isExtends() {
  48. return boundKind == EXTENDS;
  49. }
  50. public boolean isSuper() {
  51. return boundKind == SUPER;
  52. }
  53. public boolean isUnbound() {
  54. return boundKind == UNBOUND;
  55. }
  56. }