public boolean compatibleWith(MoveAttributeRefactoring ref) { if(ref.getMovedAttribute().getClassName().equals(this.movedOperation.getClassName()) && ref.getOriginalAttribute().getClassName().equals(this.originalOperation.getClassName())) { List<String> originalOperationVariables = this.originalOperation.getAllVariables(); List<String> movedOperationVariables = this.movedOperation.getAllVariables(); return originalOperationVariables.contains(ref.getOriginalAttribute().getName()) && movedOperationVariables.contains(ref.getMovedAttribute().getName()); } return false; } }
public int hashCode() { if(hashCode == 0) { int result = 17; result = 37*result + originalAttribute.hashCode(); result = 37*result + movedAttribute.hashCode(); result = 37*result + getSourceClassName().hashCode(); result = 37*result + getTargetClassName().hashCode(); hashCode = result; } return hashCode; } }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getName()).append("\t"); sb.append(movedAttribute); sb.append(" from class "); sb.append(getSourceClassName()); sb.append(" to class "); sb.append(getTargetClassName()); return sb.toString(); }
} else if (r instanceof MoveAttributeRefactoring) { MoveAttributeRefactoring ref = (MoveAttributeRefactoring) r; String attrName = ref.getMovedAttribute().getName(); rs.add(new RefactoringRelationship(r.getRefactoringType(), ref.getSourceClassName() + "#" + attrName, ref.getTargetClassName() + "#" + attrName)); } else { throw new RuntimeException("refactoring not supported");
ref = new MoveAttributeRefactoring(removedAttribute, addedAttribute);
public String getName() { return this.getRefactoringType().getDisplayName(); }
} else if (r instanceof MoveAttributeRefactoring) { MoveAttributeRefactoring ref = (MoveAttributeRefactoring) r; String attrName = ref.getMovedAttribute().getName(); rs.add(new RefactoringRelationship(refactoringTypeOf(r), ref.getSourceClassName() + "#" + attrName, ref.getTargetClassName() + "#" + attrName)); } else if (r instanceof MoveClassFolderRefactoring) { MoveClassFolderRefactoring ref = (MoveClassFolderRefactoring) r;
private MoveAttributeRefactoring processPairOfAttributes(UMLAttribute addedAttribute, UMLAttribute removedAttribute) { if(addedAttribute.getName().equals(removedAttribute.getName()) && addedAttribute.getType().equals(removedAttribute.getType())) { if(isSubclassOf(removedAttribute.getClassName(), addedAttribute.getClassName())) { PullUpAttributeRefactoring pullUpAttribute = new PullUpAttributeRefactoring(removedAttribute, addedAttribute); return pullUpAttribute; } else if(isSubclassOf(addedAttribute.getClassName(), removedAttribute.getClassName())) { PushDownAttributeRefactoring pushDownAttribute = new PushDownAttributeRefactoring(removedAttribute, addedAttribute); return pushDownAttribute; } else if(sourceClassImportsTargetClassAfterRefactoring(removedAttribute.getClassName(), addedAttribute.getClassName()) || targetClassImportsSourceClassBeforeRefactoring(removedAttribute.getClassName(), addedAttribute.getClassName())) { MoveAttributeRefactoring moveAttribute = new MoveAttributeRefactoring(removedAttribute, addedAttribute); return moveAttribute; } } return null; }
} else if (r instanceof MoveAttributeRefactoring) { MoveAttributeRefactoring ref = (MoveAttributeRefactoring) r; String attrName = ref.getMovedAttribute().getName(); rs.add(new RefactoringRelationship(r.getRefactoringType(), ref.getSourceClassName() + "#" + attrName, ref.getTargetClassName() + "#" + attrName)); } else { throw new RuntimeException("refactoring not supported");
public boolean equals(Object o) { if(this == o) { return true; } if(o instanceof MoveAttributeRefactoring) { MoveAttributeRefactoring other = (MoveAttributeRefactoring)o; return this.originalAttribute.equals(other.originalAttribute) && this.movedAttribute.equals(other.movedAttribute) && this.getSourceClassName().equals(other.getSourceClassName()) && this.getTargetClassName().equals(other.getTargetClassName()); } return false; }
UMLClassBaseDiff sourceClassDiff = getUMLClassDiff(candidate.getSourceClassName()); UMLClassBaseDiff targetClassDiff = getUMLClassDiff(candidate.getTargetClassName()); if(sourceClassDiff != null) { UMLType targetSuperclass = null; if(looksLikeSameType(addedAttribute.getType().getClassType(), candidate.getTargetClassName())) { count++; List<UMLAttribute> originalAttributes = sourceClassDiff.originalClassAttributesOfType(candidate.getTargetClassName()); List<UMLAttribute> nextAttributes = sourceClassDiff.nextClassAttributesOfType(candidate.getTargetClassName()); if(targetSuperclass != null) { originalAttributes.addAll(sourceClassDiff.originalClassAttributesOfType(targetSuperclass.getClassType()));