Skip to content

Commit

Permalink
#17 Review: minor JavaDoc improvements;
Browse files Browse the repository at this point in the history
add newInstance method for TwinImpl class;

Signed-off-by: Stefan Maute <stefan.maute@bosch-si.com>
  • Loading branch information
Stefan Maute committed Oct 29, 2019
1 parent cf333cc commit 863d5eb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
Expand Up @@ -168,7 +168,7 @@ private static TwinImpl configureTwin(final MessagingProvider messagingProvider,
final String sessionId = messagingProvider.getAuthenticationConfiguration().getSessionId();
final JsonSchemaVersion schemaVersion = messagingProvider.getMessagingConfiguration().getJsonSchemaVersion();
final OutgoingMessageFactory messageFactory = OutgoingMessageFactory.newInstance(schemaVersion, sessionId);
return new TwinImpl(messagingProvider, responseForwarder, messageFactory, bus);
return TwinImpl.newInstance(messagingProvider, responseForwarder, messageFactory, bus);
}

private static LiveImpl configureLive(final MessagingProvider messagingProvider,
Expand Down
Expand Up @@ -117,17 +117,7 @@ public final class LiveImpl extends CommonManagementImpl<LiveThingHandle, LiveFe
private final Map<Class<? extends LiveCommand>, Function<? extends LiveCommand, LiveCommandAnswerBuilder.BuildStep>>
liveCommandsFunctions;

/**
* Creates a new {@code TwinImpl} instance.
*
* @param messagingProvider implementation of underlying messaging provider.
* @param responseForwarder fast cache of response addresses.
* @param outgoingMessageFactory a factory for messages.
* @param bus the bus for message routing.
* @param schemaVersion the json schema version of the messaging protocol.
* @param sessionId the session identifier of this client.
*/
public LiveImpl(final MessagingProvider messagingProvider,
private LiveImpl(final MessagingProvider messagingProvider,
final ResponseForwarder responseForwarder,
final OutgoingMessageFactory outgoingMessageFactory,
final PointerBus bus,
Expand All @@ -147,6 +137,18 @@ public LiveImpl(final MessagingProvider messagingProvider,
liveCommandsFunctions = new IdentityHashMap<>();
}

/**
* Creates a new {@code LiveImpl} instance.
*
* @param messagingProvider implementation of underlying messaging provider.
* @param responseForwarder fast cache of response addresses.
* @param outgoingMessageFactory a factory for messages.
* @param bus the bus for message routing.
* @param schemaVersion the json schema version of the messaging protocol.
* @param sessionId the session identifier of this client.
* @param messageSerializerRegistry the registry to serialize and de-serialize messages.
* @return the new {@code LiveImpl} instance.
*/
public static LiveImpl newInstance(final MessagingProvider messagingProvider,
final ResponseForwarder responseForwarder,
final OutgoingMessageFactory outgoingMessageFactory,
Expand Down
Expand Up @@ -42,24 +42,32 @@ public final class TwinImpl extends CommonManagementImpl<TwinThingHandle, TwinFe
*/
public static final String CONSUME_TWIN_EVENTS_HANDLER = "consume-twin-events";

private TwinImpl(final MessagingProvider messagingProvider,
final ResponseForwarder responseForwarder,
final OutgoingMessageFactory outgoingMessageFactory,
final PointerBus bus) {
super(TopicPath.Channel.TWIN,
messagingProvider,
responseForwarder,
outgoingMessageFactory,
new HandlerRegistry<>(bus),
bus);
}

/**
* Creates a new {@code TwinImpl} instance.
*
* @param messagingProvider implementation of underlying messaging provider.
* @param responseForwarder fast cache of response addresses.
* @param outgoingMessageFactory a factory for messages.
* @param bus the bus for message routing.
* @return the new {@code TwinImpl} instance.
*/
public TwinImpl(final MessagingProvider messagingProvider,
public static TwinImpl newInstance(final MessagingProvider messagingProvider,
final ResponseForwarder responseForwarder,
final OutgoingMessageFactory outgoingMessageFactory,
final PointerBus bus) {
super(TopicPath.Channel.TWIN,
messagingProvider,
responseForwarder,
outgoingMessageFactory,
new HandlerRegistry<>(bus),
bus);
return new TwinImpl(messagingProvider, responseForwarder, outgoingMessageFactory, bus);
}

@Override
Expand Down
Expand Up @@ -29,8 +29,7 @@ public final class AccessTokenAuthenticationConfigurationTest {

@Test
public void testHashCodeAndEquals() {
EqualsVerifier.forClass(
AccessTokenAuthenticationConfiguration.class)
EqualsVerifier.forClass(AccessTokenAuthenticationConfiguration.class)
.usingGetClass()
.verify();
}
Expand Down
Expand Up @@ -27,16 +27,14 @@ public final class ClientCredentialsAuthenticationConfigurationTest {

@Test
public void testHashCodeAndEquals() {
EqualsVerifier.forClass(
ClientCredentialsAuthenticationConfiguration.class)
EqualsVerifier.forClass(ClientCredentialsAuthenticationConfiguration.class)
.usingGetClass()
.verify();
}

@Test
public void assertImmutability() {
assertInstancesOf(
ClientCredentialsAuthenticationConfiguration.class,
assertInstancesOf(ClientCredentialsAuthenticationConfiguration.class,
areImmutable());
}

Expand Down

0 comments on commit 863d5eb

Please sign in to comment.