1414 * guarantee it. Any other <i>ExpectedRevision</i> instances are meant for optimistic concurrency checks.
1515 * </p>
1616 */
17- public abstract class ExpectedRevision {
17+ public abstract class StreamState {
1818 /**
1919 * This writes should not conflict with anything and should always succeed.
2020 */
21- public static ExpectedRevision any () {
22- return new AnyExpectedRevision ();
21+ public static StreamState any () {
22+ return new AnyStreamState ();
2323 }
2424
2525 /**
2626 * The stream being written to should not yet exist. If it does exist, treats that as a concurrency problem.
2727 */
28- public static ExpectedRevision noStream () {
29- return new NoStreamExpectedRevision ();
28+ public static StreamState noStream () {
29+ return new NoStreamState ();
3030 }
3131
3232 /**
3333 * The stream should exist. If it or a metadata stream does not exist, treats that as a concurrency problem.
3434 */
35- public static ExpectedRevision streamExists () {
36- return new StreamExistsExpectedRevision ();
35+ public static StreamState streamExists () {
36+ return new StreamExistsState ();
3737 }
3838
3939 /**
4040 * States that the last event written to the stream should have an event revision matching your expected value.
4141 */
42- public static ExpectedRevision expectedRevision (long revision ) {
43- return new SpecificExpectedRevision (revision );
42+ public static StreamState streamRevision (long revision ) {
43+ return new StreamRevisionStreamState (revision );
4444 }
4545
46- public static ExpectedRevision fromRawLong (long revision ) {
46+ public static StreamState fromRawLong (long revision ) {
4747 if (revision == -1 )
48- return ExpectedRevision .noStream ();
48+ return StreamState .noStream ();
4949 if (revision == -2 )
50- return ExpectedRevision .any ();
50+ return StreamState .any ();
5151 if (revision == -4 )
52- return ExpectedRevision .streamExists ();
52+ return StreamState .streamExists ();
5353
5454 if (revision < 0 )
55- throw new RuntimeException (String .format ("Invalid expected revision long representation '%s'" , revision ));
55+ throw new RuntimeException (String .format ("Invalid stream revision long representation '%s'" , revision ));
5656
57- return ExpectedRevision . expectedRevision (revision );
57+ return StreamState . streamRevision (revision );
5858 }
5959
60- ExpectedRevision () {}
60+ StreamState () {}
6161
6262 abstract StreamsOuterClass .AppendReq .Options .Builder applyOnWire (StreamsOuterClass .AppendReq .Options .Builder options );
6363 abstract StreamsOuterClass .DeleteReq .Options .Builder applyOnWire (StreamsOuterClass .DeleteReq .Options .Builder options );
6464 abstract StreamsOuterClass .TombstoneReq .Options .Builder applyOnWire (StreamsOuterClass .TombstoneReq .Options .Builder options );
6565
6666 public long toRawLong () {
67- if (this instanceof NoStreamExpectedRevision )
67+ if (this instanceof NoStreamState )
6868 return -1 ;
6969
70- if (this instanceof AnyExpectedRevision )
70+ if (this instanceof AnyStreamState )
7171 return -2 ;
7272
73- if (this instanceof StreamExistsExpectedRevision )
73+ if (this instanceof StreamExistsState )
7474 return -4 ;
7575
76- SpecificExpectedRevision revision = (SpecificExpectedRevision ) this ;
76+ StreamRevisionStreamState revision = (StreamRevisionStreamState ) this ;
7777
7878 return revision .version ;
7979 }
@@ -89,7 +89,7 @@ public int hashCode() {
8989 return Objects .hash (getClass ());
9090 }
9191
92- public static class NoStreamExpectedRevision extends ExpectedRevision {
92+ public static class NoStreamState extends StreamState {
9393 @ Override
9494 public StreamsOuterClass .AppendReq .Options .Builder applyOnWire (StreamsOuterClass .AppendReq .Options .Builder options ) {
9595 return options .setNoStream (Shared .Empty .getDefaultInstance ());
@@ -107,11 +107,11 @@ public StreamsOuterClass.TombstoneReq.Options.Builder applyOnWire(StreamsOuterCl
107107
108108 @ Override
109109 public String toString () {
110- return "ExpectedNoStream " ;
110+ return "NoStreamState " ;
111111 }
112112 }
113113
114- public static class AnyExpectedRevision extends ExpectedRevision {
114+ public static class AnyStreamState extends StreamState {
115115 @ Override
116116 public StreamsOuterClass .AppendReq .Options .Builder applyOnWire (StreamsOuterClass .AppendReq .Options .Builder options ) {
117117 return options .setAny (Shared .Empty .getDefaultInstance ());
@@ -129,11 +129,11 @@ public StreamsOuterClass.TombstoneReq.Options.Builder applyOnWire(StreamsOuterCl
129129
130130 @ Override
131131 public String toString () {
132- return "ExpectedAny " ;
132+ return "AnyStreamState " ;
133133 }
134134 }
135135
136- public static class StreamExistsExpectedRevision extends ExpectedRevision {
136+ public static class StreamExistsState extends StreamState {
137137 @ Override
138138 public StreamsOuterClass .AppendReq .Options .Builder applyOnWire (StreamsOuterClass .AppendReq .Options .Builder options ) {
139139 return options .setStreamExists (Shared .Empty .getDefaultInstance ());
@@ -151,22 +151,22 @@ public StreamsOuterClass.TombstoneReq.Options.Builder applyOnWire(StreamsOuterCl
151151
152152 @ Override
153153 public String toString () {
154- return "ExpectedStreamExists " ;
154+ return "StreamExistsState " ;
155155 }
156156 }
157157
158- public static class SpecificExpectedRevision extends ExpectedRevision {
158+ public static class StreamRevisionStreamState extends StreamState {
159159 final long version ;
160160
161- SpecificExpectedRevision (long version ) {
161+ StreamRevisionStreamState (long version ) {
162162 this .version = version ;
163163 }
164164
165165 @ Override
166166 public boolean equals (Object o ) {
167167 if (this == o ) return true ;
168168 if (o == null || getClass () != o .getClass ()) return false ;
169- SpecificExpectedRevision that = (SpecificExpectedRevision ) o ;
169+ StreamRevisionStreamState that = (StreamRevisionStreamState ) o ;
170170 return version == that .version ;
171171 }
172172
0 commit comments