Skip to content

Commit

Permalink
Merge pull request #1299 from SpineEventEngine/trigger-build
Browse files Browse the repository at this point in the history
Encapsulate checking `Repository` context
  • Loading branch information
alexander-yevsyukov authored Sep 3, 2020
2 parents 6ebebcc + e5ccfbf commit eac102c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions server/src/main/java/io/spine/server/entity/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public final TypeUrl entityStateType() {
public void registerWith(BoundedContext context) {
checkNotNull(context);
boolean sameValue = context.equals(this.context);
if (this.context != null && !sameValue) {
if (hasContext() && !sameValue) {
throw newIllegalStateException(
"The repository `%s` has the Bounded Context (`%s`) assigned." +
" This operation can be performed only once." +
Expand All @@ -222,14 +222,11 @@ public void registerWith(BoundedContext context) {
}

/**
* {@inheritDoc}
*
* <p>Unlike, {@link #isOpen()}, once the repository is
* {@linkplain #registerWith(BoundedContext) initialized}, this method always returns {@code true}.
* Tells if the repository is registered in a {@code BoundedContext}.
*/
@Override
public boolean isRegistered() {
return context != null;
return hasContext();
}

/**
Expand Down Expand Up @@ -262,7 +259,7 @@ protected final boolean hasContext() {
* if the repository has no context assigned
*/
protected final BoundedContext context() {
checkState(context != null,
checkState(hasContext(),
"The repository (class: `%s`) is not registered with a `BoundedContext`.",
getClass().getName());
return context;
Expand Down Expand Up @@ -364,7 +361,7 @@ public void close() {
*/
@Override
public final boolean isOpen() {
return context != null;
return hasContext();
}

@Internal
Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* Version of this library.
*/
val coreJava = "1.5.28"
val coreJava = "1.5.29"

/**
* Versions of the Spine libraries that `core-java` depends on.
Expand Down

0 comments on commit eac102c

Please sign in to comment.