Skip to content

Commit

Permalink
[lang] Unify the function prototypes of AgentContext.
Browse files Browse the repository at this point in the history
Change the order of the formal parameters of the space creation methods
into AgentContext in order to be consistent.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Sep 3, 2017
1 parent dd1652a commit 2c917d5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ <S extends Space> S createSpace(Class<? extends SpaceSpecification<S>> spec,
* @deprecated see {@link #getOrCreateSpaceWithSpec(Class, UUID, Object...)}
*/
@Deprecated
<S extends Space> S getOrCreateSpace(Class<? extends SpaceSpecification<S>> spec,
UUID spaceUUID, Object... creationParams);
default <S extends Space> S getOrCreateSpace(Class<? extends SpaceSpecification<S>> spec,
UUID spaceUUID, Object... creationParams) {
return getOrCreateSpaceWithSpec(spec, spaceUUID, creationParams);
}

/** Retreive or create an instance of space which was created with the given specification.
*
Expand Down Expand Up @@ -149,9 +151,35 @@ <S extends Space> S getOrCreateSpaceWithSpec(Class<? extends SpaceSpecification<
* @see #getOrCreateSpaceWithID(UUID, Class, Object...)
* @see #createSpace(Class, UUID, Object...)
* @see #getSpace(UUID)
* @deprecated see {@link #getOrCreateSpaceWithID(Class, UUID, Object...)}
*/
@Deprecated
default <S extends Space> S getOrCreateSpaceWithID(UUID spaceUUID,
Class<? extends SpaceSpecification<S>> spec, Object... creationParams) {
return getOrCreateSpaceWithID(spec, spaceUUID, creationParams);
}

/** Retreive or create an instance of space with the given identifier.
*
* <p>This function tries to find a space with the given identifier.
* If none was found, this function creates a new space with the given
* specification and creation parameters.
*
* <p><strong>Caution:</strong> The <code>spaceUUID</code> parameter is given to
* the specification when creating the space.
*
* @param <S> - type of the replied space.
* @param spaceUUID - identifier of the space.
* @param spec - specification of the space for creating the space.
* @param creationParams - parameters to pass to the space constructor.
* @return the space, never <code>null</code>.
* @see #getOrCreateSpaceWithID(UUID, Class, Object...)
* @see #createSpace(Class, UUID, Object...)
* @see #getSpace(UUID)
* @since 0.6
*/
<S extends Space> S getOrCreateSpaceWithID(UUID spaceUUID,
Class<? extends SpaceSpecification<S>> spec, Object... creationParams);
<S extends Space> S getOrCreateSpaceWithID(Class<? extends SpaceSpecification<S>> spec,
UUID spaceUUID, Object... creationParams);

/** Retreive, but do not create, an instance of space following the given ID.
* This function tries to find a space that fits the given specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,14 @@ public <S extends io.sarl.lang.core.Space> S createSpace(Class<? extends SpaceSp
return this.spaceRepository.createSpace(new SpaceID(this.id, spaceUUID, spec), spec, creationParams);
}

/**
* {@inheritDoc}.
* @deprecated see {@link #getOrCreateSpaceWithSpec(Class, UUID, Object...)}.
*/
@Override
@Deprecated
public <S extends Space> S getOrCreateSpace(Class<? extends SpaceSpecification<S>> spec, UUID spaceUUID,
Object... creationParams) {
return getOrCreateSpaceWithSpec(spec, spaceUUID, creationParams);
}

@Override
public <S extends Space> S getOrCreateSpaceWithSpec(Class<? extends SpaceSpecification<S>> spec, UUID spaceUUID,
Object... creationParams) {
return this.spaceRepository.getOrCreateSpaceWithSpec(new SpaceID(this.id, spaceUUID, spec), spec, creationParams);
}

@Override
public <S extends Space> S getOrCreateSpaceWithID(UUID spaceUUID, Class<? extends SpaceSpecification<S>> spec,
public <S extends Space> S getOrCreateSpaceWithID(Class<? extends SpaceSpecification<S>> spec, UUID spaceUUID,
Object... creationParams) {
return this.spaceRepository.getOrCreateSpaceWithID(new SpaceID(this.id, spaceUUID, spec), spec, creationParams);
}
Expand Down

0 comments on commit 2c917d5

Please sign in to comment.