Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/Transition.java @ 22367:1b48778cee21
add toString() methods to transitions
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Fri, 13 Nov 2015 16:25:04 +0100 |
parents | dc83cc1f94f2 |
children |
comparison
equal
deleted
inserted
replaced
22366:78306843f20c | 22367:1b48778cee21 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.object; | 23 package com.oracle.truffle.object; |
24 | 24 |
25 import java.util.Objects; | |
26 | |
25 import com.oracle.truffle.api.object.ObjectType; | 27 import com.oracle.truffle.api.object.ObjectType; |
26 import com.oracle.truffle.api.object.Property; | 28 import com.oracle.truffle.api.object.Property; |
27 import java.util.Objects; | |
28 | 29 |
29 public abstract class Transition { | 30 public abstract class Transition { |
30 @Override | 31 @Override |
31 public int hashCode() { | 32 public int hashCode() { |
32 int result = 1; | 33 int result = 1; |
88 | 89 |
89 @Override | 90 @Override |
90 public boolean isDirect() { | 91 public boolean isDirect() { |
91 return true; | 92 return true; |
92 } | 93 } |
94 | |
95 @Override | |
96 public String toString() { | |
97 return String.format("add(%s)", getProperty()); | |
98 } | |
93 } | 99 } |
94 | 100 |
95 public static final class RemovePropertyTransition extends PropertyTransition { | 101 public static final class RemovePropertyTransition extends PropertyTransition { |
96 public RemovePropertyTransition(Property property) { | 102 public RemovePropertyTransition(Property property) { |
97 super(property); | 103 super(property); |
98 } | 104 } |
99 | 105 |
100 @Override | 106 @Override |
101 public boolean isDirect() { | 107 public boolean isDirect() { |
102 return false; | 108 return false; |
109 } | |
110 | |
111 @Override | |
112 public String toString() { | |
113 return String.format("remove(%s)", getProperty()); | |
103 } | 114 } |
104 } | 115 } |
105 | 116 |
106 public static final class ObjectTypeTransition extends Transition { | 117 public static final class ObjectTypeTransition extends Transition { |
107 private final ObjectType objectType; | 118 private final ObjectType objectType; |
129 | 140 |
130 @Override | 141 @Override |
131 public boolean isDirect() { | 142 public boolean isDirect() { |
132 return true; | 143 return true; |
133 } | 144 } |
145 | |
146 @Override | |
147 public String toString() { | |
148 return String.format("objectType(%s)", getObjectType()); | |
149 } | |
134 } | 150 } |
135 | 151 |
136 public abstract static class AbstractReplacePropertyTransition extends PropertyTransition { | 152 public abstract static class AbstractReplacePropertyTransition extends PropertyTransition { |
137 private final Property after; | 153 private final Property after; |
138 | 154 |
159 final int prime = 31; | 175 final int prime = 31; |
160 int result = super.hashCode(); | 176 int result = super.hashCode(); |
161 result = prime * result + after.hashCode(); | 177 result = prime * result + after.hashCode(); |
162 return result; | 178 return result; |
163 } | 179 } |
180 | |
181 @Override | |
182 public String toString() { | |
183 return String.format("replace(%s,%s)", getPropertyBefore(), getPropertyAfter()); | |
184 } | |
164 } | 185 } |
165 | 186 |
166 public static final class IndirectReplacePropertyTransition extends AbstractReplacePropertyTransition { | 187 public static final class IndirectReplacePropertyTransition extends AbstractReplacePropertyTransition { |
167 public IndirectReplacePropertyTransition(Property before, Property after) { | 188 public IndirectReplacePropertyTransition(Property before, Property after) { |
168 super(before, after); | 189 super(before, after); |