Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate checking Repository context #1299

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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