11package liquidjava .processor ;
22
3+ import java .util .Objects ;
4+
35import liquidjava .rj_language .Predicate ;
46import liquidjava .utils .Utils ;
57import spoon .reflect .reference .CtTypeReference ;
@@ -23,6 +25,24 @@ public VCImplication(Predicate ref) {
2325 this .refinement = ref ;
2426 }
2527
28+ public VCImplication (VCImplication implication , Predicate ref ) {
29+ this .name = implication .name ;
30+ this .type = implication .type ;
31+ this .refinement = ref ;
32+ }
33+
34+ public VCImplication getOrigin () {
35+ return new VCImplication (this , refinement .clone ());
36+ }
37+
38+ public Predicate getOriginRefinement () {
39+ return getOrigin ().getRefinement ().clone ();
40+ }
41+
42+ public VCImplication copyWithRefinement (Predicate refinement ) {
43+ return new VCImplication (this , refinement );
44+ }
45+
2646 public void setNext (VCImplication c ) {
2747 next = c ;
2848 }
@@ -47,6 +67,14 @@ public VCImplication getNext() {
4767 return next ;
4868 }
4969
70+ public boolean hasNext () {
71+ return next != null ;
72+ }
73+
74+ public boolean hasBinder () {
75+ return name != null && type != null ;
76+ }
77+
5078 public String toString () {
5179 if (name != null && type != null ) {
5280 String qualType = type .getQualifiedName ();
@@ -79,4 +107,26 @@ public VCImplication clone() {
79107 vc .next = this .next .clone ();
80108 return vc ;
81109 }
110+
111+ @ Override
112+ public int hashCode () {
113+ return Objects .hash (name , typeName (), refinement , next );
114+ }
115+
116+ @ Override
117+ public boolean equals (Object obj ) {
118+ if (this == obj )
119+ return true ;
120+ if (obj == null )
121+ return false ;
122+ if (getClass () != obj .getClass ())
123+ return false ;
124+ VCImplication other = (VCImplication ) obj ;
125+ return Objects .equals (name , other .name ) && Objects .equals (typeName (), other .typeName ())
126+ && Objects .equals (refinement , other .refinement ) && Objects .equals (next , other .next );
127+ }
128+
129+ private String typeName () {
130+ return type == null ? null : type .getQualifiedName ();
131+ }
82132}
0 commit comments