-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fact] Refactor handling of node contents #1
- Loading branch information
Showing
3 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package se.kth.spork.merge.spoon; | ||
|
||
import spoon.reflect.path.CtRole; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Class representing some form of value in a Spoon node, along with the role the value has. This is for | ||
* example the name of a method, or the value in a literal. | ||
* | ||
* @author Simon Larsén | ||
*/ | ||
class RoledValue { | ||
private final Object value; | ||
private final CtRole role; | ||
|
||
public RoledValue(Object value, CtRole role) { | ||
this.value = value; | ||
this.role = role; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public CtRole getRole() { | ||
return role; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
RoledValue roledValue1 = (RoledValue) o; | ||
return role == roledValue1.role && | ||
Objects.equals(value, roledValue1.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(value, role); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Value{" + | ||
"value=" + value + | ||
", role=" + role + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters