Skip to content

Commit 0f7e8aa

Browse files
committed
Queue changes for non-Java clients using JSON
(merge main -> ce/main 107674) [git-p4: depot-paths = "//dev/coherence-ce/main/": change = 107675]
1 parent 03a264e commit 0f7e8aa

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

prj/coherence-core/src/main/java/com/tangosol/internal/net/queue/model/QueuePollResult.java

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,41 @@
99

1010
import com.tangosol.io.AbstractEvolvable;
1111
import com.tangosol.io.ExternalizableLite;
12-
import com.tangosol.io.SerializationSupport;
1312
import com.tangosol.io.Serializer;
1413
import com.tangosol.io.SerializerAware;
1514
import com.tangosol.io.pof.EvolvablePortableObject;
1615
import com.tangosol.io.pof.PofReader;
1716
import com.tangosol.io.pof.PofWriter;
1817
import com.tangosol.util.Binary;
1918
import com.tangosol.util.ExternalizableHelper;
20-
import jakarta.json.bind.annotation.JsonbCreator;
21-
import jakarta.json.bind.annotation.JsonbNillable;
2219
import jakarta.json.bind.annotation.JsonbProperty;
2320
import jakarta.json.bind.annotation.JsonbTransient;
2421

2522
import java.io.DataInput;
2623
import java.io.DataOutput;
2724
import java.io.IOException;
28-
import java.io.ObjectStreamException;
2925

26+
/**
27+
* The result of invoking a {@link com.tangosol.internal.net.queue.processor.QueuePoll}.
28+
*/
3029
public class QueuePollResult
3130
extends AbstractEvolvable
3231
implements ExternalizableLite, EvolvablePortableObject, SerializerAware
3332
{
33+
/**
34+
* Default constructor for serialization.
35+
*/
3436
public QueuePollResult()
3537
{
3638
}
3739

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+
*/
3847
public QueuePollResult(long id, Binary binElement)
3948
{
4049
m_id = id;
@@ -52,26 +61,40 @@ public long getId()
5261
}
5362

5463
/**
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.
5666
*
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
5869
*/
5970
public Binary getBinaryElement()
6071
{
6172
return m_binElement;
6273
}
6374

6475
/**
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.
6678
*
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.
6881
*/
6982
@SuppressWarnings("unchecked")
7083
public <E> E getElement()
7184
{
7285
return (E) m_oElement;
7386
}
7487

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+
7598
// ----- EvolvablePortableObject methods --------------------------------
7699

77100
@Override
@@ -99,7 +122,7 @@ public void writeExternal(PofWriter out) throws IOException
99122
@Override
100123
public void readExternal(DataInput in) throws IOException
101124
{
102-
m_id = in.readLong();
125+
m_id = in.readLong();
103126
m_binElement = ExternalizableHelper.readObject(in);
104127
}
105128

@@ -125,11 +148,15 @@ public void setContextSerializer(Serializer serializer)
125148
if (m_binElement != null)
126149
{
127150
m_oElement = ExternalizableHelper.fromBinary(m_binElement, m_serializer);
151+
m_fPresent = true;
128152
}
129153
}
130154

131155
// ----- constants ------------------------------------------------------
132156

157+
/**
158+
* The {@link EvolvablePortableObject} version of this class.
159+
*/
133160
public static final int IMPL_VERSION = 1;
134161

135162
// ----- data members ---------------------------------------------------
@@ -151,15 +178,15 @@ public void setContextSerializer(Serializer serializer)
151178
*/
152179
private transient Serializer m_serializer;
153180

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-
159181
/**
160182
* The Object version of the element;
161183
*/
162184
@JsonbProperty("element")
163-
@JsonbNillable
164185
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;
165192
}

0 commit comments

Comments
 (0)