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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. public InterTypeFieldDeclarationImpl(AjType<?> decType, String target,
  28. int mods, String name, AjType<?> type, Type genericType) {
  29. super(decType, target, mods);
  30. this.name = name;
  31. this.type = type;
  32. this.genericType = genericType;
  33. }
  34. public InterTypeFieldDeclarationImpl(AjType<?> decType, AjType<?> targetType, Field base) {
  35. super(decType,targetType,base.getModifiers());
  36. this.name = base.getName();
  37. this.type = AjTypeSystem.getAjType(base.getType());
  38. Type gt = base.getGenericType();
  39. if (gt instanceof Class) {
  40. this.genericType = AjTypeSystem.getAjType((Class<?>)gt);
  41. } else {
  42. this.genericType = gt;
  43. }
  44. }
  45. public String getName() {
  46. return this.name;
  47. }
  48. public AjType<?> getType() {
  49. return this.type;
  50. }
  51. public Type getGenericType() {
  52. return this.genericType;
  53. }
  54. public String toString() {
  55. StringBuffer sb = new StringBuffer();
  56. sb.append(java.lang.reflect.Modifier.toString(getModifiers()));
  57. sb.append(" ");
  58. sb.append(getType().toString());
  59. sb.append(" ");
  60. sb.append(this.targetTypeName);
  61. sb.append(".");
  62. sb.append(getName());
  63. return sb.toString();
  64. }
  65. }