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