Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into fix-migrations
  • Loading branch information
dmitrykuzmin committed Sep 3, 2020
2 parents f93e2a5 + eac102c commit e3a7c76
Showing 1 changed file with 5 additions and 8 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

0 comments on commit e3a7c76

Please sign in to comment.