You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InterTypeFieldDeclarationImpl.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* *******************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Adrian Colyer Initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.internal.lang.reflect;
  13. import java.lang.reflect.Field;
  14. import java.lang.reflect.Type;
  15. import org.aspectj.lang.reflect.AjType;
  16. import org.aspectj.lang.reflect.AjTypeSystem;
  17. import org.aspectj.lang.reflect.InterTypeFieldDeclaration;
  18. /**
  19. * @author colyer
  20. *
  21. */
  22. public class InterTypeFieldDeclarationImpl extends InterTypeDeclarationImpl
  23. implements InterTypeFieldDeclaration {
  24. private String name;
  25. private AjType<?> type;
  26. private Type genericType;
  27. /**
  28. * @param decType
  29. * @param target
  30. * @param mods
  31. */
  32. public InterTypeFieldDeclarationImpl(AjType<?> decType, String target,
  33. int mods, String name, AjType<?> type, Type genericType) {
  34. super(decType, target, mods);
  35. this.name = name;
  36. this.type = type;
  37. this.genericType = genericType;
  38. }
  39. public InterTypeFieldDeclarationImpl(AjType<?> decType, AjType<?> targetType, Field base) {
  40. super(decType,targetType,base.getModifiers());
  41. this.name = base.getName();
  42. this.type = AjTypeSystem.getAjType(base.getType());
  43. Type gt = base.getGenericType();
  44. if (gt instanceof Class) {
  45. this.genericType = AjTypeSystem.getAjType((Class<?>)gt);
  46. } else {
  47. this.genericType = gt;
  48. }
  49. }
  50. /* (non-Javadoc)
  51. * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getName()
  52. */
  53. public String getName() {
  54. return this.name;
  55. }
  56. /* (non-Javadoc)
  57. * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getType()
  58. */
  59. public AjType<?> getType() {
  60. return this.type;
  61. }
  62. /* (non-Javadoc)
  63. * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getGenericType()
  64. */
  65. public Type getGenericType() {
  66. return this.genericType;
  67. }
  68. public String toString() {
  69. StringBuffer sb = new StringBuffer();
  70. sb.append(java.lang.reflect.Modifier.toString(getModifiers()));
  71. sb.append(" ");
  72. sb.append(getType().toString());
  73. sb.append(" ");
  74. sb.append(this.targetTypeName);
  75. sb.append(".");
  76. sb.append(getName());
  77. return sb.toString();
  78. }
  79. }