9
9
10
10
import com .tangosol .io .AbstractEvolvable ;
11
11
import com .tangosol .io .ExternalizableLite ;
12
- import com .tangosol .io .SerializationSupport ;
13
12
import com .tangosol .io .Serializer ;
14
13
import com .tangosol .io .SerializerAware ;
15
14
import com .tangosol .io .pof .EvolvablePortableObject ;
16
15
import com .tangosol .io .pof .PofReader ;
17
16
import com .tangosol .io .pof .PofWriter ;
18
17
import com .tangosol .util .Binary ;
19
18
import com .tangosol .util .ExternalizableHelper ;
20
- import jakarta .json .bind .annotation .JsonbCreator ;
21
- import jakarta .json .bind .annotation .JsonbNillable ;
22
19
import jakarta .json .bind .annotation .JsonbProperty ;
23
20
import jakarta .json .bind .annotation .JsonbTransient ;
24
21
25
22
import java .io .DataInput ;
26
23
import java .io .DataOutput ;
27
24
import java .io .IOException ;
28
- import java .io .ObjectStreamException ;
29
25
26
+ /**
27
+ * The result of invoking a {@link com.tangosol.internal.net.queue.processor.QueuePoll}.
28
+ */
30
29
public class QueuePollResult
31
30
extends AbstractEvolvable
32
31
implements ExternalizableLite , EvolvablePortableObject , SerializerAware
33
32
{
33
+ /**
34
+ * Default constructor for serialization.
35
+ */
34
36
public QueuePollResult ()
35
37
{
36
38
}
37
39
40
+ /**
41
+ * Create a {@link QueuePollResult}.
42
+ *
43
+ * @param id the id of the polled element
44
+ * @param binElement the serialized {@link Binary} value polled from the queue
45
+ * or {@code null} if the queue was empty
46
+ */
38
47
public QueuePollResult (long id , Binary binElement )
39
48
{
40
49
m_id = id ;
@@ -52,26 +61,40 @@ public long getId()
52
61
}
53
62
54
63
/**
55
- * Return the serialized binary value of the polled element.
64
+ * Return the serialized binary value of the polled element,
65
+ * or {@code null} if the queue was empty.
56
66
*
57
- * @return the serialized binary value of the polled element
67
+ * @return the serialized binary value of the polled element,
68
+ * or {@code null} if the queue was empty
58
69
*/
59
70
public Binary getBinaryElement ()
60
71
{
61
72
return m_binElement ;
62
73
}
63
74
64
75
/**
65
- * Return the deserialized object form of the polled element.
76
+ * Return the deserialized object form of the polled element,
77
+ * or {@code null} if the queue was empty.
66
78
*
67
- * @return the deserialized object form of the polled element
79
+ * @return the deserialized object form of the polled element,
80
+ * or {@code null} if the queue was empty.
68
81
*/
69
82
@ SuppressWarnings ("unchecked" )
70
83
public <E > E getElement ()
71
84
{
72
85
return (E ) m_oElement ;
73
86
}
74
87
88
+ /**
89
+ * Return {@code true} if this result has a deserialized value.
90
+ *
91
+ * @return {@code true} if this result has a deserialized value
92
+ */
93
+ public boolean isPresent ()
94
+ {
95
+ return m_fPresent ;
96
+ }
97
+
75
98
// ----- EvolvablePortableObject methods --------------------------------
76
99
77
100
@ Override
@@ -99,7 +122,7 @@ public void writeExternal(PofWriter out) throws IOException
99
122
@ Override
100
123
public void readExternal (DataInput in ) throws IOException
101
124
{
102
- m_id = in .readLong ();
125
+ m_id = in .readLong ();
103
126
m_binElement = ExternalizableHelper .readObject (in );
104
127
}
105
128
@@ -125,11 +148,15 @@ public void setContextSerializer(Serializer serializer)
125
148
if (m_binElement != null )
126
149
{
127
150
m_oElement = ExternalizableHelper .fromBinary (m_binElement , m_serializer );
151
+ m_fPresent = true ;
128
152
}
129
153
}
130
154
131
155
// ----- constants ------------------------------------------------------
132
156
157
+ /**
158
+ * The {@link EvolvablePortableObject} version of this class.
159
+ */
133
160
public static final int IMPL_VERSION = 1 ;
134
161
135
162
// ----- data members ---------------------------------------------------
@@ -151,15 +178,15 @@ public void setContextSerializer(Serializer serializer)
151
178
*/
152
179
private transient Serializer m_serializer ;
153
180
154
- /**
155
- * A flag to indicate the {@link #m_oElement} field was deserialized from the binary value.
156
- */
157
- private transient boolean m_fHasObjectValue ;
158
-
159
181
/**
160
182
* The Object version of the element;
161
183
*/
162
184
@ JsonbProperty ("element" )
163
- @ JsonbNillable
164
185
private transient Object m_oElement ;
186
+
187
+ /**
188
+ * Indicates if a deserialized value is present in the {@link #m_oElement} field.
189
+ */
190
+ @ JsonbProperty ("present" )
191
+ private transient boolean m_fPresent ;
165
192
}
0 commit comments