@@ -70,6 +70,19 @@ public Meta() {}
70
70
this .allowDiskUse = source .allowDiskUse ;
71
71
}
72
72
73
+ /**
74
+ * Return whether the maximum time limit for processing operations is set.
75
+ *
76
+ * @return {@code true} if set; {@code false} otherwise.
77
+ * @since 3.4.12
78
+ */
79
+ public boolean hasMaxTime () {
80
+
81
+ Long maxTimeMsec = getMaxTimeMsec ();
82
+
83
+ return maxTimeMsec != null && maxTimeMsec > 0 ;
84
+ }
85
+
73
86
/**
74
87
* @return {@literal null} if not set.
75
88
*/
@@ -78,6 +91,26 @@ public Long getMaxTimeMsec() {
78
91
return getValue (MetaKey .MAX_TIME_MS .key );
79
92
}
80
93
94
+ /**
95
+ * Returns the required maximum time limit in milliseconds or throws {@link IllegalStateException} if the maximum time
96
+ * limit is not set.
97
+ *
98
+ * @return the maximum time limit in milliseconds for processing operations.
99
+ * @throws IllegalStateException if the maximum time limit is not set
100
+ * @see #hasMaxTime()
101
+ * @since 3.4.12
102
+ */
103
+ public Long getRequiredMaxTimeMsec () {
104
+
105
+ Long maxTimeMsec = getMaxTimeMsec ();
106
+
107
+ if (maxTimeMsec == null ) {
108
+ throw new IllegalStateException ("Maximum time limit in milliseconds not set" );
109
+ }
110
+
111
+ return maxTimeMsec ;
112
+ }
113
+
81
114
/**
82
115
* Set the maximum time limit in milliseconds for processing operations.
83
116
*
@@ -112,12 +145,13 @@ public void setMaxTime(Duration timeout) {
112
145
}
113
146
114
147
/**
115
- * Add a comment to the query that is propagated to the profile log .
148
+ * Return whether the comment is set .
116
149
*
117
- * @param comment
150
+ * @return {@code true} if set; {@code false} otherwise.
151
+ * @since 3.4.12
118
152
*/
119
- public void setComment ( String comment ) {
120
- setValue ( MetaKey . COMMENT . key , comment );
153
+ public boolean hasComment ( ) {
154
+ return StringUtils . hasText ( getComment () );
121
155
}
122
156
123
157
/**
@@ -128,6 +162,34 @@ public String getComment() {
128
162
return getValue (MetaKey .COMMENT .key );
129
163
}
130
164
165
+ /**
166
+ * Returns the required comment or throws {@link IllegalStateException} if the comment is not set.
167
+ *
168
+ * @return the comment.
169
+ * @throws IllegalStateException if the comment is not set
170
+ * @see #hasComment()
171
+ * @since 3.4.12
172
+ */
173
+ public String getRequiredComment () {
174
+
175
+ String comment = getComment ();
176
+
177
+ if (comment == null ) {
178
+ throw new IllegalStateException ("Comment not set" );
179
+ }
180
+
181
+ return comment ;
182
+ }
183
+
184
+ /**
185
+ * Add a comment to the query that is propagated to the profile log.
186
+ *
187
+ * @param comment
188
+ */
189
+ public void setComment (String comment ) {
190
+ setValue (MetaKey .COMMENT .key , comment );
191
+ }
192
+
131
193
/**
132
194
* @return {@literal null} if not set.
133
195
* @since 2.1
0 commit comments