@Test public void tryLinkToSubscription() { final EntityService entityService = Replicant.context().getEntityService(); final Entity entity = safeAction( () -> entityService.findOrCreateEntity( "MyEntity", String.class, ValueUtil.randomInt() ) ); final Subscription subscription1 = createSubscription( new ChannelAddress( 1, 0, 1 ) ); safeAction( () -> entity.tryLinkToSubscription( subscription1 ) ); safeAction( () -> assertEquals( entity.getSubscriptions().size(), 1 ) ); entity.tryLinkToSubscription( subscription1 ); safeAction( () -> assertEquals( entity.getSubscriptions().size(), 1 ) ); }
void tryLinkToSubscription( @Nonnull final Subscription subscription ) { if ( !_subscriptions.containsKey( subscription.getAddress() ) ) { linkToSubscription( subscription ); } }
Entity extends ReplicantService { void tryLinkToSubscription( @Nonnull final Subscription subscription ) { if ( !_subscriptions.containsKey( subscription.getAddress() ) ) { linkToSubscription( subscription ); } } }
Entity extends ReplicantService { void tryLinkToSubscription( @Nonnull final Subscription subscription ) { if ( !_subscriptions.containsKey( subscription.getAddress() ) ) { linkToSubscription( subscription ); } } Entity( @Nullable final ReplicantContext context,
          @Nullable final String name,
          @Nonnull final Class<?> type,
          final int id ); }
Entity extends ReplicantService { void tryLinkToSubscription( @Nonnull final Subscription subscription ) { if ( !_subscriptions.containsKey( subscription.getAddress() ) ) { linkToSubscription( subscription ); } } Entity( @Nullable final ReplicantContext context,
          @Nullable final String name,
          @Nonnull final Class<?> type,
          final int id ); @Nonnull String getName(); @Nonnull Class<?> getType(); int getId(); @Nonnull Object getUserObject(); @Observable( name = "userObject" ) @Nullable Object maybeUserObject(); @Nonnull @Observable( expectSetter = false ) Collection<Subscription> getSubscriptions(); @Override String toString(); }
Entity extends ReplicantService { void tryLinkToSubscription( @Nonnull final Subscription subscription ) { if ( !_subscriptions.containsKey( subscription.getAddress() ) ) { linkToSubscription( subscription ); } } Entity( @Nullable final ReplicantContext context,
          @Nullable final String name,
          @Nonnull final Class<?> type,
          final int id ); @Nonnull String getName(); @Nonnull Class<?> getType(); int getId(); @Nonnull Object getUserObject(); @Observable( name = "userObject" ) @Nullable Object maybeUserObject(); @Nonnull @Observable( expectSetter = false ) Collection<Subscription> getSubscriptions(); @Override String toString();  }