File tree 2 files changed +57
-0
lines changed
recaf-core/src/main/java/software/coley/recaf/util/analysis/value
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,56 @@ default int getSize() {
67
67
return 1 ;
68
68
}
69
69
70
+ /**
71
+ * @param value
72
+ * Value to check against.
73
+ *
74
+ * @return {@code true} when the known value is equal to the given value.
75
+ */
76
+ default boolean isSame (int value ) {
77
+ return value ().isPresent () && value ().getAsInt () == value ;
78
+ }
79
+
80
+ /**
81
+ * @param value
82
+ * Value to check against.
83
+ *
84
+ * @return {@code true} when the known value is less than the given value.
85
+ */
86
+ default boolean isLessThan (int value ) {
87
+ return value ().isPresent () && value ().getAsInt () < value ;
88
+ }
89
+
90
+ /**
91
+ * @param value
92
+ * Value to check against.
93
+ *
94
+ * @return {@code true} when the known value is less than or equal to the given value.
95
+ */
96
+ default boolean isLessThanOrEqual (int value ) {
97
+ return value ().isPresent () && value ().getAsInt () <= value ;
98
+ }
99
+
100
+ /**
101
+ * @param value
102
+ * Value to check against.
103
+ *
104
+ * @return {@code true} when the known value is greater than the given value.
105
+ */
106
+ default boolean isGreaterThan (int value ) {
107
+ return value ().isPresent () && value ().getAsInt () > value ;
108
+ }
109
+
110
+ /**
111
+ * @param value
112
+ * Value to check against.
113
+ *
114
+ * @return {@code true} when the known value is greater than or equal to the given value.
115
+ */
116
+ default boolean isGreaterThanOrEqual (int value ) {
117
+ return value ().isPresent () && value ().getAsInt () >= value ;
118
+ }
119
+
70
120
@ Nonnull
71
121
default IntValue add (int incr ) {
72
122
OptionalInt value = value ();
Original file line number Diff line number Diff line change @@ -114,6 +114,13 @@ default boolean isNull() {
114
114
return nullness () == Nullness .NULL ;
115
115
}
116
116
117
+ /**
118
+ * @return {@code true} when this value is known to be <b>not</b> {@code null}.
119
+ */
120
+ default boolean isNotNull () {
121
+ return nullness () == Nullness .NOT_NULL ;
122
+ }
123
+
117
124
@ Override
118
125
default int getSize () {
119
126
return 1 ;
You can’t perform that action at this time.
0 commit comments