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.

NewMemberClassTypeMunger.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* *******************************************************************
  2. * Copyright (c) 2010 SpringSource, 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://www.eclipse.org/legal/epl-v10.html
  8. * ******************************************************************/
  9. package org.aspectj.weaver;
  10. import java.io.IOException;
  11. import java.util.List;
  12. import org.aspectj.bridge.ISourceLocation;
  13. /**
  14. * Weaver representation of an intertype declared member class. The munger captures the name of the type being declared and the
  15. * target.
  16. *
  17. * @author Andy Clement
  18. * @since 1.6.9
  19. */
  20. public class NewMemberClassTypeMunger extends ResolvedTypeMunger {
  21. private UnresolvedType targetType;
  22. private String memberTypeName; // short (last part of) name
  23. private int version = 1; // 1.6.9m2
  24. public NewMemberClassTypeMunger(UnresolvedType targetType, String memberTypeName) {
  25. super(ResolvedTypeMunger.InnerClass, null);
  26. this.targetType = targetType;
  27. this.memberTypeName = memberTypeName;
  28. }
  29. @Override
  30. public void write(CompressingDataOutputStream stream) throws IOException {
  31. kind.write(stream);
  32. stream.writeInt(version);
  33. targetType.write(stream);
  34. stream.writeUTF(memberTypeName);
  35. writeSourceLocation(stream);
  36. writeOutTypeAliases(stream);
  37. }
  38. public static ResolvedTypeMunger readInnerClass(VersionedDataInputStream stream, ISourceContext context) throws IOException {
  39. /* int version = */stream.readInt();
  40. UnresolvedType targetType = UnresolvedType.read(stream);
  41. String memberTypeName = stream.readUTF();
  42. ISourceLocation sourceLocation = readSourceLocation(stream);
  43. List<String> typeVarAliases = readInTypeAliases(stream);
  44. NewMemberClassTypeMunger newInstance = new NewMemberClassTypeMunger(targetType, memberTypeName);
  45. newInstance.setTypeVariableAliases(typeVarAliases);
  46. newInstance.setSourceLocation(sourceLocation);
  47. return newInstance;
  48. }
  49. public UnresolvedType getTargetType() {
  50. return targetType;
  51. }
  52. public UnresolvedType getDeclaringType() {
  53. return targetType;
  54. }
  55. public String getMemberTypeName() {
  56. return memberTypeName;
  57. }
  58. public int hashCode() {
  59. int result = 17;
  60. result = 37 * result + kind.hashCode();
  61. result = 37 * result + memberTypeName.hashCode();
  62. result = 37 * result + targetType.hashCode();
  63. result = 37 * result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
  64. return result;
  65. }
  66. public boolean equals(Object other) {
  67. if (!(other instanceof NewMemberClassTypeMunger)) {
  68. return false;
  69. }
  70. NewMemberClassTypeMunger o = (NewMemberClassTypeMunger) other;
  71. return ((kind == null) ? (o.kind == null) : kind.equals(o.kind))
  72. && memberTypeName.equals(o.memberTypeName)
  73. && targetType.equals(o.targetType)
  74. && ((typeVariableAliases == null) ? (o.typeVariableAliases == null) : typeVariableAliases
  75. .equals(o.typeVariableAliases));
  76. }
  77. }