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.

Relationship.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* *******************************************************************
  2. * Copyright (c) 2003,2010 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. * Mik Kersten initial implementation
  11. * Andy Clement Extensions for better IDE representation
  12. * ******************************************************************/
  13. package org.aspectj.asm.internal;
  14. import java.util.List;
  15. import org.aspectj.asm.IRelationship;
  16. /**
  17. * @author Mik Kersten
  18. * @author Andy Clement
  19. */
  20. public class Relationship implements IRelationship {
  21. private static final long serialVersionUID = 3855166397957609120L;
  22. private String name;
  23. private Kind kind;
  24. private boolean isAffects;
  25. private String sourceHandle;
  26. private List<String> targets;
  27. private boolean hasRuntimeTest;
  28. public Relationship(String name, Kind kind, String sourceHandle, List<String> targets, boolean runtimeTest) {
  29. this.name = name;
  30. this.isAffects = name.equals("advises") || name.equals("declares on") || name.equals("softens")
  31. || name.equals("matched by") || name.equals("declared on") || name.equals("annotates");
  32. this.kind = kind;
  33. this.sourceHandle = sourceHandle;
  34. this.targets = targets;
  35. this.hasRuntimeTest = runtimeTest;
  36. }
  37. public String getName() {
  38. return name;
  39. }
  40. public Kind getKind() {
  41. return kind;
  42. }
  43. public String toString() {
  44. return name;
  45. }
  46. public String getSourceHandle() {
  47. return sourceHandle;
  48. }
  49. // TODO should be a Set and not a list
  50. public List<String> getTargets() {
  51. return targets;
  52. }
  53. public void addTarget(String handle) {
  54. if (targets.contains(handle)) {
  55. return;
  56. }
  57. targets.add(handle);
  58. }
  59. public boolean hasRuntimeTest() {
  60. return hasRuntimeTest;
  61. }
  62. /**
  63. * Return the direction of the relationship. It might be affects or affected-by. The direction enables the incremental model
  64. * repair code to do the right thing.
  65. *
  66. * @return true if is an affects relationship: advises/declareson/softens/matchedby/declaredon/annotates
  67. */
  68. public boolean isAffects() {
  69. return isAffects;
  70. }
  71. }