target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void invariantObserversLinked() { final Observer observer1 = Arez.context().observer( new CountAndObserveProcedure() ); final Observer observer2 = Arez.context().observer( new CountAndObserveProcedure() ); final Observer observer3 = Arez.context().observer( new CountAndObserveProcedure() ); setupReadWriteTransaction(); observer1.setState( Observer.Flags.STATE_UP_TO_DATE ); observer2.setState( Observer.Flags.STATE_POSSIBLY_STALE ); observer3.setState( Observer.Flags.STATE_STALE ); final ObservableValue<?> observableValue = Arez.context().observable(); observer1.getDependencies().add( observableValue ); observer2.getDependencies().add( observableValue ); observableValue.rawAddObserver( observer1 ); observableValue.rawAddObserver( observer2 ); observableValue.rawAddObserver( observer3 ); observableValue.setLeastStaleObserverState( Observer.Flags.STATE_UP_TO_DATE ); assertInvariantFailure( observableValue::invariantObserversLinked, "Arez-0077: ObservableValue named '" + observableValue.getName() + "' has observer named '" + observer3.getName() + "' which does not contain ObservableValue as dependency." ); observer3.getDependencies().add( observableValue ); observableValue.invariantObserversLinked(); }
void invariantObserversLinked() { if ( Arez.shouldCheckInvariants() ) { getObservers().forEach( observer -> invariant( () -> observer.getDependencies().contains( this ), () -> "Arez-0077: ObservableValue named '" + getName() + "' has observer " + "named '" + observer.getName() + "' which does not contain " + "ObservableValue as dependency." ) ); } }
ObservableValue extends Node { void invariantObserversLinked() { if ( Arez.shouldCheckInvariants() ) { getObservers().forEach( observer -> invariant( () -> observer.getDependencies().contains( this ), () -> "Arez-0077: ObservableValue named '" + getName() + "' has observer " + "named '" + observer.getName() + "' which does not contain " + "ObservableValue as dependency." ) ); } } }
ObservableValue extends Node { void invariantObserversLinked() { if ( Arez.shouldCheckInvariants() ) { getObservers().forEach( observer -> invariant( () -> observer.getDependencies().contains( this ), () -> "Arez-0077: ObservableValue named '" + getName() + "' has observer " + "named '" + observer.getName() + "' which does not contain " + "ObservableValue as dependency." ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void invariantObserversLinked() { if ( Arez.shouldCheckInvariants() ) { getObservers().forEach( observer -> invariant( () -> observer.getDependencies().contains( this ), () -> "Arez-0077: ObservableValue named '" + getName() + "' has observer " + "named '" + observer.getName() + "' which does not contain " + "ObservableValue as dependency." ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void invariantObserversLinked() { if ( Arez.shouldCheckInvariants() ) { getObservers().forEach( observer -> invariant( () -> observer.getDependencies().contains( this ), () -> "Arez-0077: ObservableValue named '" + getName() + "' has observer " + "named '" + observer.getName() + "' which does not contain " + "ObservableValue as dependency." ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void queueForDeactivation() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer observer = computableValue.getObserver(); final ObservableValue<?> observableValue = computableValue.getObservableValue(); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); assertFalse( observableValue.isPendingDeactivation() ); observableValue.queueForDeactivation(); assertTrue( observableValue.isPendingDeactivation() ); final List<ObservableValue<?>> pendingDeactivations = context.getTransaction().getPendingDeactivations(); assertNotNull( pendingDeactivations ); assertEquals( pendingDeactivations.size(), 1 ); assertTrue( pendingDeactivations.contains( observableValue ) ); }
void queueForDeactivation() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0071: Attempt to invoke queueForDeactivation on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivateNow, () -> "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue is not able to be deactivated." ); invariant( () -> !hasObservers(), () -> "Arez-0073: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue has observers." ); } if ( !isPendingDeactivation() ) { getContext().getTransaction().queueForDeactivation( this ); } }
ObservableValue extends Node { void queueForDeactivation() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0071: Attempt to invoke queueForDeactivation on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivateNow, () -> "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue is not able to be deactivated." ); invariant( () -> !hasObservers(), () -> "Arez-0073: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue has observers." ); } if ( !isPendingDeactivation() ) { getContext().getTransaction().queueForDeactivation( this ); } } }
ObservableValue extends Node { void queueForDeactivation() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0071: Attempt to invoke queueForDeactivation on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivateNow, () -> "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue is not able to be deactivated." ); invariant( () -> !hasObservers(), () -> "Arez-0073: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue has observers." ); } if ( !isPendingDeactivation() ) { getContext().getTransaction().queueForDeactivation( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void queueForDeactivation() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0071: Attempt to invoke queueForDeactivation on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivateNow, () -> "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue is not able to be deactivated." ); invariant( () -> !hasObservers(), () -> "Arez-0073: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue has observers." ); } if ( !isPendingDeactivation() ) { getContext().getTransaction().queueForDeactivation( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void queueForDeactivation() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0071: Attempt to invoke queueForDeactivation on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivateNow, () -> "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue is not able to be deactivated." ); invariant( () -> !hasObservers(), () -> "Arez-0073: Attempted to invoke queueForDeactivation() on ObservableValue named '" + getName() + "' but ObservableValue has observers." ); } if ( !isPendingDeactivation() ) { getContext().getTransaction().queueForDeactivation( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void queueForDeactivation_observableIsNotAbleToBeDeactivated() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ObservableValue<?> observableValue = context.observable(); assertFalse( observableValue.isPendingDeactivation() ); assertInvariantFailure( observableValue::queueForDeactivation, "Arez-0072: Attempted to invoke queueForDeactivation() on ObservableValue named '" + observableValue.getName() + "' but ObservableValue is not able to be deactivated." ); }
boolean isPendingDeactivation() { return _pendingDeactivation; }
ObservableValue extends Node { boolean isPendingDeactivation() { return _pendingDeactivation; } }
ObservableValue extends Node { boolean isPendingDeactivation() { return _pendingDeactivation; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { boolean isPendingDeactivation() { return _pendingDeactivation; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { boolean isPendingDeactivation() { return _pendingDeactivation; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void resetPendingDeactivation() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer observer = computableValue.getObserver(); final ObservableValue<?> observableValue = computableValue.getObservableValue(); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); observableValue.markAsPendingDeactivation(); assertTrue( observableValue.isPendingDeactivation() ); observableValue.resetPendingDeactivation(); assertFalse( observableValue.isPendingDeactivation() ); }
void resetPendingDeactivation() { _pendingDeactivation = false; }
ObservableValue extends Node { void resetPendingDeactivation() { _pendingDeactivation = false; } }
ObservableValue extends Node { void resetPendingDeactivation() { _pendingDeactivation = false; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void resetPendingDeactivation() { _pendingDeactivation = false; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void resetPendingDeactivation() { _pendingDeactivation = false; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void safeGetString_generatesError() { final String text = ArezUtil.safeGetString( () -> { throw new RuntimeException( "X" ); } ); assertTrue( text.startsWith( "Exception generated whilst attempting to get supplied message.\n" + "java.lang.RuntimeException: X\n" ) ); }
@Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String safeGetString( @Nonnull final Supplier<String> message ) { try { return message.get(); } catch ( final Throwable t ) { return "Exception generated whilst attempting to get supplied message.\n" + throwableToString( t ); } }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String safeGetString( @Nonnull final Supplier<String> message ) { try { return message.get(); } catch ( final Throwable t ) { return "Exception generated whilst attempting to get supplied message.\n" + throwableToString( t ); } } }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String safeGetString( @Nonnull final Supplier<String> message ) { try { return message.get(); } catch ( final Throwable t ) { return "Exception generated whilst attempting to get supplied message.\n" + throwableToString( t ); } } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String safeGetString( @Nonnull final Supplier<String> message ) { try { return message.get(); } catch ( final Throwable t ) { return "Exception generated whilst attempting to get supplied message.\n" + throwableToString( t ); } } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String safeGetString( @Nonnull final Supplier<String> message ) { try { return message.get(); } catch ( final Throwable t ) { return "Exception generated whilst attempting to get supplied message.\n" + throwableToString( t ); } } private ArezUtil(); }
@Test public void canDeactivate() { final ArezContext context = Arez.context(); final Observer randomObserver = context.observer( new CountAndObserveProcedure() ); setCurrentTransaction( randomObserver ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer observer = computableValue.getObserver(); final ObservableValue<?> observableValue = computableValue.getObservableValue(); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); assertTrue( observableValue.canDeactivate() ); assertTrue( observableValue.canDeactivateNow() ); observableValue.addObserver( randomObserver ); randomObserver.getDependencies().add( observableValue ); assertTrue( observableValue.canDeactivate() ); assertFalse( observableValue.canDeactivateNow() ); observableValue.removeObserver( randomObserver ); randomObserver.getDependencies().remove( observableValue ); assertTrue( observableValue.canDeactivate() ); assertTrue( observableValue.canDeactivateNow() ); final Disposable keepAliveLock = computableValue.keepAlive(); assertTrue( observableValue.canDeactivate() ); assertFalse( observableValue.canDeactivateNow() ); keepAliveLock.dispose(); assertTrue( observableValue.canDeactivate() ); assertTrue( observableValue.canDeactivateNow() ); }
boolean canDeactivate() { return isComputableValue() && !getObserver().isKeepAlive(); }
ObservableValue extends Node { boolean canDeactivate() { return isComputableValue() && !getObserver().isKeepAlive(); } }
ObservableValue extends Node { boolean canDeactivate() { return isComputableValue() && !getObserver().isKeepAlive(); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { boolean canDeactivate() { return isComputableValue() && !getObserver().isKeepAlive(); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { boolean canDeactivate() { return isComputableValue() && !getObserver().isKeepAlive(); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void deactivate() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer observer = computableValue.getObserver(); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); final ObservableValue<?> observableValue = computableValue.getObservableValue(); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); observableValue.deactivate(); assertEquals( observer.getState(), Observer.Flags.STATE_INACTIVE ); }
void deactivate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0060: Attempt to invoke deactivate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivate, () -> "Arez-0061: Invoked deactivate on ObservableValue named '" + getName() + "' but " + "ObservableValue can not be deactivated. Either owner is null or the associated " + "ComputableValue has keepAlive enabled." ); } assert null != _observer; if ( _observer.isActive() ) { final boolean shouldPropagateDeactivateEvent = willPropagateSpyEvents() && !getObservers().isEmpty(); _observer.setState( Observer.Flags.STATE_INACTIVE ); if ( willPropagateSpyEvents() && shouldPropagateDeactivateEvent ) { reportSpyEvent( new ComputableValueDeactivateEvent( _observer.getComputableValue().asInfo() ) ); } } }
ObservableValue extends Node { void deactivate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0060: Attempt to invoke deactivate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivate, () -> "Arez-0061: Invoked deactivate on ObservableValue named '" + getName() + "' but " + "ObservableValue can not be deactivated. Either owner is null or the associated " + "ComputableValue has keepAlive enabled." ); } assert null != _observer; if ( _observer.isActive() ) { final boolean shouldPropagateDeactivateEvent = willPropagateSpyEvents() && !getObservers().isEmpty(); _observer.setState( Observer.Flags.STATE_INACTIVE ); if ( willPropagateSpyEvents() && shouldPropagateDeactivateEvent ) { reportSpyEvent( new ComputableValueDeactivateEvent( _observer.getComputableValue().asInfo() ) ); } } } }
ObservableValue extends Node { void deactivate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0060: Attempt to invoke deactivate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivate, () -> "Arez-0061: Invoked deactivate on ObservableValue named '" + getName() + "' but " + "ObservableValue can not be deactivated. Either owner is null or the associated " + "ComputableValue has keepAlive enabled." ); } assert null != _observer; if ( _observer.isActive() ) { final boolean shouldPropagateDeactivateEvent = willPropagateSpyEvents() && !getObservers().isEmpty(); _observer.setState( Observer.Flags.STATE_INACTIVE ); if ( willPropagateSpyEvents() && shouldPropagateDeactivateEvent ) { reportSpyEvent( new ComputableValueDeactivateEvent( _observer.getComputableValue().asInfo() ) ); } } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void deactivate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0060: Attempt to invoke deactivate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivate, () -> "Arez-0061: Invoked deactivate on ObservableValue named '" + getName() + "' but " + "ObservableValue can not be deactivated. Either owner is null or the associated " + "ComputableValue has keepAlive enabled." ); } assert null != _observer; if ( _observer.isActive() ) { final boolean shouldPropagateDeactivateEvent = willPropagateSpyEvents() && !getObservers().isEmpty(); _observer.setState( Observer.Flags.STATE_INACTIVE ); if ( willPropagateSpyEvents() && shouldPropagateDeactivateEvent ) { reportSpyEvent( new ComputableValueDeactivateEvent( _observer.getComputableValue().asInfo() ) ); } } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void deactivate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0060: Attempt to invoke deactivate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( this::canDeactivate, () -> "Arez-0061: Invoked deactivate on ObservableValue named '" + getName() + "' but " + "ObservableValue can not be deactivated. Either owner is null or the associated " + "ComputableValue has keepAlive enabled." ); } assert null != _observer; if ( _observer.isActive() ) { final boolean shouldPropagateDeactivateEvent = willPropagateSpyEvents() && !getObservers().isEmpty(); _observer.setState( Observer.Flags.STATE_INACTIVE ); if ( willPropagateSpyEvents() && shouldPropagateDeactivateEvent ) { reportSpyEvent( new ComputableValueDeactivateEvent( _observer.getComputableValue().asInfo() ) ); } } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void activate() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer observer = computableValue.getObserver(); observer.setState( Observer.Flags.STATE_INACTIVE ); final ObservableValue<?> observableValue = computableValue.getObservableValue(); assertEquals( observer.getState(), Observer.Flags.STATE_INACTIVE ); observableValue.activate(); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); }
void activate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0062: Attempt to invoke activate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( () -> null != _observer, () -> "Arez-0063: Invoked activate on ObservableValue named '" + getName() + "' when owner is null." ); assert null != _observer; invariant( _observer::isInactive, () -> "Arez-0064: Invoked activate on ObservableValue named '" + getName() + "' when " + "ObservableValue is already active." ); } assert null != _observer; _observer.setState( Observer.Flags.STATE_UP_TO_DATE ); if ( willPropagateSpyEvents() ) { reportSpyEvent( new ComputableValueActivateEvent( _observer.getComputableValue().asInfo() ) ); } }
ObservableValue extends Node { void activate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0062: Attempt to invoke activate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( () -> null != _observer, () -> "Arez-0063: Invoked activate on ObservableValue named '" + getName() + "' when owner is null." ); assert null != _observer; invariant( _observer::isInactive, () -> "Arez-0064: Invoked activate on ObservableValue named '" + getName() + "' when " + "ObservableValue is already active." ); } assert null != _observer; _observer.setState( Observer.Flags.STATE_UP_TO_DATE ); if ( willPropagateSpyEvents() ) { reportSpyEvent( new ComputableValueActivateEvent( _observer.getComputableValue().asInfo() ) ); } } }
ObservableValue extends Node { void activate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0062: Attempt to invoke activate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( () -> null != _observer, () -> "Arez-0063: Invoked activate on ObservableValue named '" + getName() + "' when owner is null." ); assert null != _observer; invariant( _observer::isInactive, () -> "Arez-0064: Invoked activate on ObservableValue named '" + getName() + "' when " + "ObservableValue is already active." ); } assert null != _observer; _observer.setState( Observer.Flags.STATE_UP_TO_DATE ); if ( willPropagateSpyEvents() ) { reportSpyEvent( new ComputableValueActivateEvent( _observer.getComputableValue().asInfo() ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void activate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0062: Attempt to invoke activate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( () -> null != _observer, () -> "Arez-0063: Invoked activate on ObservableValue named '" + getName() + "' when owner is null." ); assert null != _observer; invariant( _observer::isInactive, () -> "Arez-0064: Invoked activate on ObservableValue named '" + getName() + "' when " + "ObservableValue is already active." ); } assert null != _observer; _observer.setState( Observer.Flags.STATE_UP_TO_DATE ); if ( willPropagateSpyEvents() ) { reportSpyEvent( new ComputableValueActivateEvent( _observer.getComputableValue().asInfo() ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void activate() { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getContext().isTransactionActive(), () -> "Arez-0062: Attempt to invoke activate on ObservableValue named '" + getName() + "' when there is no active transaction." ); invariant( () -> null != _observer, () -> "Arez-0063: Invoked activate on ObservableValue named '" + getName() + "' when owner is null." ); assert null != _observer; invariant( _observer::isInactive, () -> "Arez-0064: Invoked activate on ObservableValue named '" + getName() + "' when " + "ObservableValue is already active." ); } assert null != _observer; _observer.setState( Observer.Flags.STATE_UP_TO_DATE ); if ( willPropagateSpyEvents() ) { reportSpyEvent( new ComputableValueActivateEvent( _observer.getComputableValue().asInfo() ) ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void reportObserved() { final ArezContext context = Arez.context(); setupReadOnlyTransaction( context ); final ObservableValue<?> observableValue = context.observable(); assertNotEquals( observableValue.getLastTrackerTransactionId(), context.getTransaction().getId() ); assertEquals( context.getTransaction().safeGetObservables().size(), 0 ); observableValue.reportObserved(); assertEquals( observableValue.getLastTrackerTransactionId(), context.getTransaction().getId() ); assertEquals( context.getTransaction().safeGetObservables().size(), 1 ); assertTrue( context.getTransaction().safeGetObservables().contains( observableValue ) ); }
public void reportObserved() { getContext().getTransaction().observe( this ); }
ObservableValue extends Node { public void reportObserved() { getContext().getTransaction().observe( this ); } }
ObservableValue extends Node { public void reportObserved() { getContext().getTransaction().observe( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { public void reportObserved() { getContext().getTransaction().observe( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { public void reportObserved() { getContext().getTransaction().observe( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void reportObservedIfTrackingTransactionActive() { final ArezContext context = Arez.context(); final ObservableValue<?> observableValue = context.observable(); observableValue.reportObservedIfTrackingTransactionActive(); context.safeAction( observableValue::reportObservedIfTrackingTransactionActive, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); assertThrows( () -> context.safeAction( observableValue::reportObservedIfTrackingTransactionActive ) ); final Observer observer = context.observer( observableValue::reportObservedIfTrackingTransactionActive ); assertTrue( observer.getDependencies().contains( observableValue ) ); }
public void reportObservedIfTrackingTransactionActive() { if ( getContext().isTrackingTransactionActive() ) { reportObserved(); } }
ObservableValue extends Node { public void reportObservedIfTrackingTransactionActive() { if ( getContext().isTrackingTransactionActive() ) { reportObserved(); } } }
ObservableValue extends Node { public void reportObservedIfTrackingTransactionActive() { if ( getContext().isTrackingTransactionActive() ) { reportObserved(); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { public void reportObservedIfTrackingTransactionActive() { if ( getContext().isTrackingTransactionActive() ) { reportObserved(); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { public void reportObservedIfTrackingTransactionActive() { if ( getContext().isTrackingTransactionActive() ) { reportObserved(); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void preReportChanged() { final ArezContext context = Arez.context(); final Observer observer = newReadWriteObserver( context ); setCurrentTransaction( observer ); final ObservableValue<?> observableValue = context.observable(); observableValue.preReportChanged(); }
@OmitSymbol( unless = "arez.check_invariants" ) public void preReportChanged() { if ( Arez.shouldCheckInvariants() ) { getContext().getTransaction().preReportChanged( this ); } }
ObservableValue extends Node { @OmitSymbol( unless = "arez.check_invariants" ) public void preReportChanged() { if ( Arez.shouldCheckInvariants() ) { getContext().getTransaction().preReportChanged( this ); } } }
ObservableValue extends Node { @OmitSymbol( unless = "arez.check_invariants" ) public void preReportChanged() { if ( Arez.shouldCheckInvariants() ) { getContext().getTransaction().preReportChanged( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { @OmitSymbol( unless = "arez.check_invariants" ) public void preReportChanged() { if ( Arez.shouldCheckInvariants() ) { getContext().getTransaction().preReportChanged( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { @OmitSymbol( unless = "arez.check_invariants" ) public void preReportChanged() { if ( Arez.shouldCheckInvariants() ) { getContext().getTransaction().preReportChanged( this ); } } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void preReportChanged_onDisposedObservable() { final ArezContext context = Arez.context(); setCurrentTransaction( newReadWriteObserver( context ) ); final ObservableValue<?> observableValue = context.observable(); observableValue.setWorkState( ObservableValue.DISPOSED ); assertInvariantFailure( observableValue::preReportChanged, "Arez-0144: Invoked reportChanged on transaction named '" + Transaction.current().getName() + "' for ObservableValue named '" + observableValue.getName() + "' where the ObservableValue is disposed." ); }
void setWorkState( final int workState ) { _workState = workState; }
ObservableValue extends Node { void setWorkState( final int workState ) { _workState = workState; } }
ObservableValue extends Node { void setWorkState( final int workState ) { _workState = workState; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void setWorkState( final int workState ) { _workState = workState; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void setWorkState( final int workState ) { _workState = workState; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void reportChanged() { final ArezContext context = Arez.context(); final Observer observer = newReadWriteObserver( context ); setCurrentTransaction( observer ); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); final ObservableValue<?> observableValue = context.observable(); observableValue.setLeastStaleObserverState( Observer.Flags.STATE_UP_TO_DATE ); observableValue.addObserver( observer ); observer.getDependencies().add( observableValue ); assertNotEquals( observableValue.getLastTrackerTransactionId(), context.getTransaction().getId() ); assertEquals( context.getTransaction().safeGetObservables().size(), 0 ); observableValue.reportChanged(); assertEquals( observer.getState(), Observer.Flags.STATE_STALE ); }
public void reportChanged() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChanged( this ); }
ObservableValue extends Node { public void reportChanged() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChanged( this ); } }
ObservableValue extends Node { public void reportChanged() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { public void reportChanged() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { public void reportChanged() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void reportPossiblyChanged() { final ArezContext context = Arez.context(); final Observer observer = newReadWriteObserver( context ); setCurrentTransaction( observer ); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer derivation = computableValue.getObserver(); final ObservableValue<?> observableValue = computableValue.getObservableValue(); derivation.setState( Observer.Flags.STATE_UP_TO_DATE ); observableValue.setLeastStaleObserverState( Observer.Flags.STATE_UP_TO_DATE ); observableValue.addObserver( observer ); observer.getDependencies().add( observableValue ); assertNotEquals( observableValue.getLastTrackerTransactionId(), context.getTransaction().getId() ); assertEquals( context.getTransaction().safeGetObservables().size(), 0 ); observableValue.reportPossiblyChanged(); assertEquals( observer.getState(), Observer.Flags.STATE_POSSIBLY_STALE ); }
void reportPossiblyChanged() { getContext().getTransaction().reportPossiblyChanged( this ); }
ObservableValue extends Node { void reportPossiblyChanged() { getContext().getTransaction().reportPossiblyChanged( this ); } }
ObservableValue extends Node { void reportPossiblyChanged() { getContext().getTransaction().reportPossiblyChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void reportPossiblyChanged() { getContext().getTransaction().reportPossiblyChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void reportPossiblyChanged() { getContext().getTransaction().reportPossiblyChanged( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void reportChangeConfirmed() { final ArezContext context = Arez.context(); final Observer observer = newReadWriteObserver( context ); setCurrentTransaction( observer ); observer.setState( Observer.Flags.STATE_POSSIBLY_STALE ); final ComputableValue<String> computableValue = context.computable( () -> "" ); final Observer derivation = computableValue.getObserver(); final ObservableValue<?> observableValue = computableValue.getObservableValue(); derivation.setState( Observer.Flags.STATE_UP_TO_DATE ); observableValue.setLeastStaleObserverState( Observer.Flags.STATE_POSSIBLY_STALE ); observableValue.addObserver( observer ); observer.getDependencies().add( observableValue ); assertNotEquals( observableValue.getLastTrackerTransactionId(), context.getTransaction().getId() ); assertEquals( context.getTransaction().safeGetObservables().size(), 0 ); observableValue.reportChangeConfirmed(); assertEquals( observer.getState(), Observer.Flags.STATE_STALE ); }
void reportChangeConfirmed() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChangeConfirmed( this ); }
ObservableValue extends Node { void reportChangeConfirmed() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChangeConfirmed( this ); } }
ObservableValue extends Node { void reportChangeConfirmed() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChangeConfirmed( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { void reportChangeConfirmed() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChangeConfirmed( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { void reportChangeConfirmed() { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObservableValueChangeEvent( asInfo(), getObservableValue() ) ); } getContext().getTransaction().reportChangeConfirmed( this ); } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void throwableToString() { final String text = ArezUtil.throwableToString( new RuntimeException( "X" ) ); assertTrue( text.startsWith( "java.lang.RuntimeException: X\n" ) ); }
@Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
@Test public void asInfo() { final ObservableValue<String> observableValue = Arez.context().observable(); final ObservableValueInfo info = observableValue.asInfo(); assertEquals( info.getName(), observableValue.getName() ); }
@SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObservableValueInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0196: ObservableValue.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObservableValueInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; }
ObservableValue extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObservableValueInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0196: ObservableValue.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObservableValueInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } }
ObservableValue extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObservableValueInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0196: ObservableValue.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObservableValueInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); }
ObservableValue extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObservableValueInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0196: ObservableValue.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObservableValueInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
ObservableValue extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObservableValueInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0196: ObservableValue.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObservableValueInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } ObservableValue( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Observer observer, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Override void dispose(); @Override boolean isDisposed(); void reportObserved(); void reportObservedIfTrackingTransactionActive(); @OmitSymbol( unless = "arez.check_invariants" ) void preReportChanged(); void reportChanged(); }
@Test public void basicOperationIntegerId() { final Integer id = ValueUtil.randomInt(); final Component component = new Component( Arez.context(), ValueUtil.randomString(), id, ValueUtil.randomString(), null, null ); assertEquals( component.getId(), id ); }
@Nonnull public Object getId() { return _id; }
Component implements Disposable { @Nonnull public Object getId() { return _id; } }
Component implements Disposable { @Nonnull public Object getId() { return _id; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); }
Component implements Disposable { @Nonnull public Object getId() { return _id; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
Component implements Disposable { @Nonnull public Object getId() { return _id; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
@Test public void complete() { final ArezContext context = Arez.context(); final String name = ValueUtil.randomString(); final Component component = context.component( ValueUtil.randomString(), ValueUtil.randomString(), name ); final ObservableValue<?> observableValue1 = context.observable(); final ComputableValue<?> computableValue1 = context.computable( () -> "" ); final Observer observer1 = context.observer( AbstractTest::observeADependency ); component.addObservableValue( observableValue1 ); component.addComputableValue( computableValue1 ); component.addObserver( observer1 ); assertFalse( component.isComplete() ); component.complete(); assertTrue( component.isComplete() ); assertEquals( component.getObservableValues().size(), 1 ); assertEquals( component.getComputableValues().size(), 1 ); assertEquals( component.getObservers().size(), 1 ); }
public void complete() { if ( !_complete ) { _complete = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo component = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentCreateCompleteEvent( component ) ); } } }
Component implements Disposable { public void complete() { if ( !_complete ) { _complete = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo component = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentCreateCompleteEvent( component ) ); } } } }
Component implements Disposable { public void complete() { if ( !_complete ) { _complete = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo component = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentCreateCompleteEvent( component ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); }
Component implements Disposable { public void complete() { if ( !_complete ) { _complete = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo component = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentCreateCompleteEvent( component ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
Component implements Disposable { public void complete() { if ( !_complete ) { _complete = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo component = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentCreateCompleteEvent( component ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
@Test public void dispose() { final ArezContext context = Arez.context(); final String name = ValueUtil.randomString(); final Component component = context.component( ValueUtil.randomString(), ValueUtil.randomString(), name ); final ObservableValue<?> observableValue1 = context.observable( component, ValueUtil.randomString(), null, null ); final ObservableValue<?> observableValue2 = context.observable( component, ValueUtil.randomString(), null, null ); final ComputableValue<?> computableValue1 = context.computable( component, ValueUtil.randomString(), () -> "", null, null ); final ComputableValue<?> computableValue2 = context.computable( component, ValueUtil.randomString(), () -> "", null, null ); final Procedure action = AbstractTest::observeADependency; final Observer observer1 = context.observer( component, null, action, Observer.Flags.RUN_LATER ); final Observer observer2 = context.observer( component, null, action, Observer.Flags.RUN_LATER ); assertEquals( component.getObservableValues().size(), 2 ); assertEquals( component.getComputableValues().size(), 2 ); assertEquals( component.getObservers().size(), 2 ); assertFalse( Disposable.isDisposed( component ) ); assertFalse( Disposable.isDisposed( observableValue1 ) ); assertFalse( Disposable.isDisposed( observableValue2 ) ); assertFalse( Disposable.isDisposed( observer1 ) ); assertFalse( Disposable.isDisposed( observer2 ) ); assertFalse( Disposable.isDisposed( computableValue1 ) ); assertFalse( Disposable.isDisposed( computableValue2 ) ); assertTrue( context.isComponentPresent( component.getType(), component.getId() ) ); component.dispose(); assertFalse( context.isComponentPresent( component.getType(), component.getId() ) ); assertEquals( component.getObservableValues().size(), 0 ); assertEquals( component.getComputableValues().size(), 0 ); assertEquals( component.getObservers().size(), 0 ); assertTrue( Disposable.isDisposed( component ) ); assertTrue( Disposable.isDisposed( observableValue1 ) ); assertTrue( Disposable.isDisposed( observableValue2 ) ); assertTrue( Disposable.isDisposed( observer1 ) ); assertTrue( Disposable.isDisposed( observer2 ) ); assertTrue( Disposable.isDisposed( computableValue1 ) ); assertTrue( Disposable.isDisposed( computableValue2 ) ); }
@Override public void dispose() { if ( !_disposed ) { _disposed = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeStartEvent( info ) ); } getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, () -> { if ( null != _preDispose ) { _preDispose.call(); } getContext().deregisterComponent( this ); new ArrayList<>( _observers ).forEach( o -> Disposable.dispose( o ) ); new ArrayList<>( _computableValues ).forEach( v -> Disposable.dispose( v ) ); new ArrayList<>( _observableValues ).forEach( o -> Disposable.dispose( o ) ); if ( null != _postDispose ) { _postDispose.call(); } }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeCompleteEvent( info ) ); } } }
Component implements Disposable { @Override public void dispose() { if ( !_disposed ) { _disposed = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeStartEvent( info ) ); } getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, () -> { if ( null != _preDispose ) { _preDispose.call(); } getContext().deregisterComponent( this ); new ArrayList<>( _observers ).forEach( o -> Disposable.dispose( o ) ); new ArrayList<>( _computableValues ).forEach( v -> Disposable.dispose( v ) ); new ArrayList<>( _observableValues ).forEach( o -> Disposable.dispose( o ) ); if ( null != _postDispose ) { _postDispose.call(); } }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeCompleteEvent( info ) ); } } } }
Component implements Disposable { @Override public void dispose() { if ( !_disposed ) { _disposed = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeStartEvent( info ) ); } getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, () -> { if ( null != _preDispose ) { _preDispose.call(); } getContext().deregisterComponent( this ); new ArrayList<>( _observers ).forEach( o -> Disposable.dispose( o ) ); new ArrayList<>( _computableValues ).forEach( v -> Disposable.dispose( v ) ); new ArrayList<>( _observableValues ).forEach( o -> Disposable.dispose( o ) ); if ( null != _postDispose ) { _postDispose.call(); } }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeCompleteEvent( info ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); }
Component implements Disposable { @Override public void dispose() { if ( !_disposed ) { _disposed = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeStartEvent( info ) ); } getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, () -> { if ( null != _preDispose ) { _preDispose.call(); } getContext().deregisterComponent( this ); new ArrayList<>( _observers ).forEach( o -> Disposable.dispose( o ) ); new ArrayList<>( _computableValues ).forEach( v -> Disposable.dispose( v ) ); new ArrayList<>( _observableValues ).forEach( o -> Disposable.dispose( o ) ); if ( null != _postDispose ) { _postDispose.call(); } }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeCompleteEvent( info ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
Component implements Disposable { @Override public void dispose() { if ( !_disposed ) { _disposed = true; if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeStartEvent( info ) ); } getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, () -> { if ( null != _preDispose ) { _preDispose.call(); } getContext().deregisterComponent( this ); new ArrayList<>( _observers ).forEach( o -> Disposable.dispose( o ) ); new ArrayList<>( _computableValues ).forEach( v -> Disposable.dispose( v ) ); new ArrayList<>( _observableValues ).forEach( o -> Disposable.dispose( o ) ); if ( null != _postDispose ) { _postDispose.call(); } }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( Arez.areSpiesEnabled() && getContext().getSpy().willPropagateSpyEvents() ) { final ComponentInfo info = getContext().getSpy().asComponentInfo( this ); getContext().getSpy().reportSpyEvent( new ComponentDisposeCompleteEvent( info ) ); } } } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
@Test public void asInfo() { final ArezContext context = Arez.context(); final Component component = context.component( ValueUtil.randomString(), ValueUtil.randomString(), ValueUtil.randomString() ); final ComponentInfo info = component.asInfo(); assertEquals( info.getId(), component.getId() ); assertEquals( info.getName(), component.getName() ); assertEquals( info.getType(), component.getType() ); }
@SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ComponentInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ComponentInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; }
Component implements Disposable { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ComponentInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ComponentInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } }
Component implements Disposable { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ComponentInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ComponentInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); }
Component implements Disposable { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ComponentInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ComponentInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
Component implements Disposable { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ComponentInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ComponentInfoImpl( this ); } return Arez.areSpiesEnabled() ? _info : null; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
@Test public void asInfo_spyDisabled() { ArezTestUtil.disableSpies(); final ArezContext context = Arez.context(); final Component component = context.component( ValueUtil.randomString(), ValueUtil.randomString(), ValueUtil.randomString() ); assertInvariantFailure( component::asInfo, "Arez-0194: Component.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); }
Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> Arez.areNamesEnabled() || null == name, () -> "Arez-0037: Component passed a name '" + name + "' but Arez.areNamesEnabled() is false" ); invariant( () -> Arez.areZonesEnabled() || null == context, () -> "Arez-0175: Component passed a context but Arez.areZonesEnabled() is false" ); } _context = Arez.areZonesEnabled() ? Objects.requireNonNull( context ) : null; _type = Objects.requireNonNull( type ); _id = Objects.requireNonNull( id ); _name = Arez.areNamesEnabled() ? Objects.requireNonNull( name ) : null; _preDispose = preDispose; _postDispose = postDispose; }
Component implements Disposable { Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> Arez.areNamesEnabled() || null == name, () -> "Arez-0037: Component passed a name '" + name + "' but Arez.areNamesEnabled() is false" ); invariant( () -> Arez.areZonesEnabled() || null == context, () -> "Arez-0175: Component passed a context but Arez.areZonesEnabled() is false" ); } _context = Arez.areZonesEnabled() ? Objects.requireNonNull( context ) : null; _type = Objects.requireNonNull( type ); _id = Objects.requireNonNull( id ); _name = Arez.areNamesEnabled() ? Objects.requireNonNull( name ) : null; _preDispose = preDispose; _postDispose = postDispose; } }
Component implements Disposable { Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> Arez.areNamesEnabled() || null == name, () -> "Arez-0037: Component passed a name '" + name + "' but Arez.areNamesEnabled() is false" ); invariant( () -> Arez.areZonesEnabled() || null == context, () -> "Arez-0175: Component passed a context but Arez.areZonesEnabled() is false" ); } _context = Arez.areZonesEnabled() ? Objects.requireNonNull( context ) : null; _type = Objects.requireNonNull( type ); _id = Objects.requireNonNull( id ); _name = Arez.areNamesEnabled() ? Objects.requireNonNull( name ) : null; _preDispose = preDispose; _postDispose = postDispose; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); }
Component implements Disposable { Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> Arez.areNamesEnabled() || null == name, () -> "Arez-0037: Component passed a name '" + name + "' but Arez.areNamesEnabled() is false" ); invariant( () -> Arez.areZonesEnabled() || null == context, () -> "Arez-0175: Component passed a context but Arez.areZonesEnabled() is false" ); } _context = Arez.areZonesEnabled() ? Objects.requireNonNull( context ) : null; _type = Objects.requireNonNull( type ); _id = Objects.requireNonNull( id ); _name = Arez.areNamesEnabled() ? Objects.requireNonNull( name ) : null; _preDispose = preDispose; _postDispose = postDispose; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
Component implements Disposable { Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> Arez.areNamesEnabled() || null == name, () -> "Arez-0037: Component passed a name '" + name + "' but Arez.areNamesEnabled() is false" ); invariant( () -> Arez.areZonesEnabled() || null == context, () -> "Arez-0175: Component passed a context but Arez.areZonesEnabled() is false" ); } _context = Arez.areZonesEnabled() ? Objects.requireNonNull( context ) : null; _type = Objects.requireNonNull( type ); _id = Objects.requireNonNull( id ); _name = Arez.areNamesEnabled() ? Objects.requireNonNull( name ) : null; _preDispose = preDispose; _postDispose = postDispose; } Component( @Nullable final ArezContext context, @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull String getType(); @Nonnull Object getId(); @Nonnull String getName(); @Override void dispose(); @Override boolean isDisposed(); @Nonnull @Override String toString(); boolean isComplete(); void complete(); }
@Test public void invariantDependenciesBackLink() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); setCurrentTransaction( observer ); final ObservableValue<?> observableValue = Arez.context().observable(); observer.getDependencies().add( observableValue ); assertInvariantFailure( () -> observer.invariantDependenciesBackLink( "TEST1" ), "Arez-0090: TEST1: Observer named '" + observer.getName() + "' has ObservableValue " + "dependency named '" + observableValue.getName() + "' which does not contain the observer in " + "the list of observers." ); observableValue.addObserver( observer ); observer.invariantDependenciesBackLink( "TEST2" ); }
void invariantDependenciesBackLink( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( () -> observable.getObservers().contains( this ), () -> "Arez-0090: " + context + ": Observer named '" + getName() + "' has ObservableValue dependency named '" + observable.getName() + "' which does not contain the observer in the list of " + "observers." ) ); invariantComputableValueObserverState(); } }
Observer extends Node { void invariantDependenciesBackLink( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( () -> observable.getObservers().contains( this ), () -> "Arez-0090: " + context + ": Observer named '" + getName() + "' has ObservableValue dependency named '" + observable.getName() + "' which does not contain the observer in the list of " + "observers." ) ); invariantComputableValueObserverState(); } } }
Observer extends Node { void invariantDependenciesBackLink( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( () -> observable.getObservers().contains( this ), () -> "Arez-0090: " + context + ": Observer named '" + getName() + "' has ObservableValue dependency named '" + observable.getName() + "' which does not contain the observer in the list of " + "observers." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void invariantDependenciesBackLink( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( () -> observable.getObservers().contains( this ), () -> "Arez-0090: " + context + ": Observer named '" + getName() + "' has ObservableValue dependency named '" + observable.getName() + "' which does not contain the observer in the list of " + "observers." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void invariantDependenciesBackLink( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( () -> observable.getObservers().contains( this ), () -> "Arez-0090: " + context + ": Observer named '" + getName() + "' has ObservableValue dependency named '" + observable.getName() + "' which does not contain the observer in the list of " + "observers." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void invariantDependenciesNotDisposed() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); setCurrentTransaction( observer ); final ObservableValue<?> observableValue = Arez.context().observable(); observer.getDependencies().add( observableValue ); observableValue.addObserver( observer ); observableValue.setWorkState( ObservableValue.DISPOSED ); assertInvariantFailure( observer::invariantDependenciesNotDisposed, "Arez-0091: Observer named '" + observer.getName() + "' has ObservableValue dependency named '" + observableValue.getName() + "' which is disposed." ); observableValue.setWorkState( 0 ); observer.invariantDependenciesNotDisposed(); }
void invariantDependenciesNotDisposed() { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( observable::isNotDisposed, () -> "Arez-0091: Observer named '" + getName() + "' has " + "ObservableValue dependency named '" + observable.getName() + "' which is disposed." ) ); invariantComputableValueObserverState(); } }
Observer extends Node { void invariantDependenciesNotDisposed() { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( observable::isNotDisposed, () -> "Arez-0091: Observer named '" + getName() + "' has " + "ObservableValue dependency named '" + observable.getName() + "' which is disposed." ) ); invariantComputableValueObserverState(); } } }
Observer extends Node { void invariantDependenciesNotDisposed() { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( observable::isNotDisposed, () -> "Arez-0091: Observer named '" + getName() + "' has " + "ObservableValue dependency named '" + observable.getName() + "' which is disposed." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void invariantDependenciesNotDisposed() { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( observable::isNotDisposed, () -> "Arez-0091: Observer named '" + getName() + "' has " + "ObservableValue dependency named '" + observable.getName() + "' which is disposed." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void invariantDependenciesNotDisposed() { if ( Arez.shouldCheckInvariants() ) { getDependencies().forEach( observable -> invariant( observable::isNotDisposed, () -> "Arez-0091: Observer named '" + getName() + "' has " + "ObservableValue dependency named '" + observable.getName() + "' which is disposed." ) ); invariantComputableValueObserverState(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void invariantDependenciesUnique() { final ArezContext context = Arez.context(); final ObservableValue<Object> observable = context.observable(); final Observer observer = context.observer( observable::reportObserved ); observer.invariantDependenciesUnique( "TEST1" ); observer.getDependencies().add( observable ); assertInvariantFailure( () -> observer.invariantDependenciesUnique( "TEST2" ), "Arez-0089: TEST2: The set of dependencies in observer named '" + observer.getName() + "' is not unique. Current list: '[" + observable.getName() + ", " + observable.getName() + "]'." ); }
void invariantDependenciesUnique( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getDependencies().size() == new HashSet<>( getDependencies() ).size(), () -> "Arez-0089: " + context + ": The set of dependencies in observer named '" + getName() + "' is not unique. Current list: '" + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "'." ); } }
Observer extends Node { void invariantDependenciesUnique( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getDependencies().size() == new HashSet<>( getDependencies() ).size(), () -> "Arez-0089: " + context + ": The set of dependencies in observer named '" + getName() + "' is not unique. Current list: '" + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "'." ); } } }
Observer extends Node { void invariantDependenciesUnique( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getDependencies().size() == new HashSet<>( getDependencies() ).size(), () -> "Arez-0089: " + context + ": The set of dependencies in observer named '" + getName() + "' is not unique. Current list: '" + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "'." ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void invariantDependenciesUnique( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getDependencies().size() == new HashSet<>( getDependencies() ).size(), () -> "Arez-0089: " + context + ": The set of dependencies in observer named '" + getName() + "' is not unique. Current list: '" + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "'." ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void invariantDependenciesUnique( @Nonnull final String context ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> getDependencies().size() == new HashSet<>( getDependencies() ).size(), () -> "Arez-0089: " + context + ": The set of dependencies in observer named '" + getName() + "' is not unique. Current list: '" + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "'." ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void invariantState() { final ArezContext context = Arez.context(); final ObservableValue<Object> observable = context.observable(); final Observer observer = context.observer( new CountingProcedure(), Observer.Flags.RUN_LATER ); observer.invariantState(); observer.getDependencies().add( observable ); assertInvariantFailure( observer::invariantState, "Arez-0092: Observer named '" + observer.getName() + "' is inactive " + "but still has dependencies: [" + observable.getName() + "]." ); }
void invariantState() { if ( Arez.shouldCheckInvariants() ) { if ( isInactive() && !isDisposing() ) { invariant( () -> getDependencies().isEmpty(), () -> "Arez-0092: Observer named '" + getName() + "' is inactive but still has dependencies: " + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "." ); } if ( null != _computableValue && _computableValue.isNotDisposed() ) { final ObservableValue<?> observable = _computableValue.getObservableValue(); invariant( () -> Objects.equals( observable.isComputableValue() ? observable.getObserver() : null, this ), () -> "Arez-0093: Observer named '" + getName() + "' is associated with an ObservableValue that " + "does not link back to observer." ); } } }
Observer extends Node { void invariantState() { if ( Arez.shouldCheckInvariants() ) { if ( isInactive() && !isDisposing() ) { invariant( () -> getDependencies().isEmpty(), () -> "Arez-0092: Observer named '" + getName() + "' is inactive but still has dependencies: " + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "." ); } if ( null != _computableValue && _computableValue.isNotDisposed() ) { final ObservableValue<?> observable = _computableValue.getObservableValue(); invariant( () -> Objects.equals( observable.isComputableValue() ? observable.getObserver() : null, this ), () -> "Arez-0093: Observer named '" + getName() + "' is associated with an ObservableValue that " + "does not link back to observer." ); } } } }
Observer extends Node { void invariantState() { if ( Arez.shouldCheckInvariants() ) { if ( isInactive() && !isDisposing() ) { invariant( () -> getDependencies().isEmpty(), () -> "Arez-0092: Observer named '" + getName() + "' is inactive but still has dependencies: " + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "." ); } if ( null != _computableValue && _computableValue.isNotDisposed() ) { final ObservableValue<?> observable = _computableValue.getObservableValue(); invariant( () -> Objects.equals( observable.isComputableValue() ? observable.getObserver() : null, this ), () -> "Arez-0093: Observer named '" + getName() + "' is associated with an ObservableValue that " + "does not link back to observer." ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void invariantState() { if ( Arez.shouldCheckInvariants() ) { if ( isInactive() && !isDisposing() ) { invariant( () -> getDependencies().isEmpty(), () -> "Arez-0092: Observer named '" + getName() + "' is inactive but still has dependencies: " + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "." ); } if ( null != _computableValue && _computableValue.isNotDisposed() ) { final ObservableValue<?> observable = _computableValue.getObservableValue(); invariant( () -> Objects.equals( observable.isComputableValue() ? observable.getObserver() : null, this ), () -> "Arez-0093: Observer named '" + getName() + "' is associated with an ObservableValue that " + "does not link back to observer." ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void invariantState() { if ( Arez.shouldCheckInvariants() ) { if ( isInactive() && !isDisposing() ) { invariant( () -> getDependencies().isEmpty(), () -> "Arez-0092: Observer named '" + getName() + "' is inactive but still has dependencies: " + getDependencies().stream().map( Node::getName ).collect( Collectors.toList() ) + "." ); } if ( null != _computableValue && _computableValue.isNotDisposed() ) { final ObservableValue<?> observable = _computableValue.getObservableValue(); invariant( () -> Objects.equals( observable.isComputableValue() ? observable.getObserver() : null, this ), () -> "Arez-0093: Observer named '" + getName() + "' is associated with an ObservableValue that " + "does not link back to observer." ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void throwableToString_with_NestedThrowable() { final RuntimeException exception = new RuntimeException( "X", new IOException( "Y" ) ); final String text = ArezUtil.throwableToString( exception ); assertTrue( text.startsWith( "java.lang.RuntimeException: X\n" ) ); assertTrue( text.contains( "\nCaused by: java.io.IOException: Y\n" ) ); }
@Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
ArezUtil { @Nonnull @OmitSymbol( unless = "arez.enable_names" ) static String throwableToString( @Nonnull final Throwable throwable ) { final StringBuilder sb = new StringBuilder(); Throwable t = throwable; while ( null != t ) { addCausedByPrefix( sb ); sb.append( t.toString() ); for ( final StackTraceElement element : t.getStackTrace() ) { sb.append( "\n at " ).append( element ); } t = t.getCause(); } return sb.toString(); } private ArezUtil(); }
@Test public void replaceDependencies() { final ArezContext context = Arez.context(); final ObservableValue<Object> observable = context.observable(); final Observer observer = context.observer( new CountingProcedure(), Observer.Flags.AREZ_OR_NO_DEPENDENCIES ); final List<ObservableValue<?>> originalDependencies = observer.getDependencies(); assertTrue( originalDependencies.isEmpty() ); context.safeAction( () -> { final List<ObservableValue<?>> newDependencies = new ArrayList<>(); newDependencies.add( observable ); observable.rawAddObserver( observer ); observer.replaceDependencies( newDependencies ); assertEquals( observer.getDependencies().size(), 1 ); assertNotSame( observer.getDependencies(), originalDependencies ); assertTrue( observer.getDependencies().contains( observable ) ); }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); }
void replaceDependencies( @Nonnull final List<ObservableValue<?>> dependencies ) { if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Pre replaceDependencies" ); } _dependencies = Objects.requireNonNull( dependencies ); if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Post replaceDependencies" ); invariantDependenciesBackLink( "Post replaceDependencies" ); invariantDependenciesNotDisposed(); } }
Observer extends Node { void replaceDependencies( @Nonnull final List<ObservableValue<?>> dependencies ) { if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Pre replaceDependencies" ); } _dependencies = Objects.requireNonNull( dependencies ); if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Post replaceDependencies" ); invariantDependenciesBackLink( "Post replaceDependencies" ); invariantDependenciesNotDisposed(); } } }
Observer extends Node { void replaceDependencies( @Nonnull final List<ObservableValue<?>> dependencies ) { if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Pre replaceDependencies" ); } _dependencies = Objects.requireNonNull( dependencies ); if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Post replaceDependencies" ); invariantDependenciesBackLink( "Post replaceDependencies" ); invariantDependenciesNotDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void replaceDependencies( @Nonnull final List<ObservableValue<?>> dependencies ) { if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Pre replaceDependencies" ); } _dependencies = Objects.requireNonNull( dependencies ); if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Post replaceDependencies" ); invariantDependenciesBackLink( "Post replaceDependencies" ); invariantDependenciesNotDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void replaceDependencies( @Nonnull final List<ObservableValue<?>> dependencies ) { if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Pre replaceDependencies" ); } _dependencies = Objects.requireNonNull( dependencies ); if ( Arez.shouldCheckInvariants() ) { invariantDependenciesUnique( "Post replaceDependencies" ); invariantDependenciesBackLink( "Post replaceDependencies" ); invariantDependenciesNotDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void clearDependencies() { final ArezContext context = Arez.context(); final ObservableValue<?> observableValue1 = context.observable(); final ObservableValue<?> observableValue2 = context.observable(); final Observer observer = context.observer( () -> { observableValue1.reportObserved(); observableValue2.reportObserved(); } ); assertEquals( observer.getDependencies().size(), 2 ); assertEquals( observableValue1.getObservers().size(), 1 ); assertEquals( observableValue2.getObservers().size(), 1 ); context.safeAction( observer::clearDependencies, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); assertEquals( observer.getDependencies().size(), 0 ); assertEquals( observableValue1.getObservers().size(), 0 ); assertEquals( observableValue2.getObservers().size(), 0 ); }
void clearDependencies() { getDependencies().forEach( dependency -> { dependency.removeObserver( this ); if ( !dependency.hasObservers() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } ); getDependencies().clear(); }
Observer extends Node { void clearDependencies() { getDependencies().forEach( dependency -> { dependency.removeObserver( this ); if ( !dependency.hasObservers() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } ); getDependencies().clear(); } }
Observer extends Node { void clearDependencies() { getDependencies().forEach( dependency -> { dependency.removeObserver( this ); if ( !dependency.hasObservers() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } ); getDependencies().clear(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void clearDependencies() { getDependencies().forEach( dependency -> { dependency.removeObserver( this ); if ( !dependency.hasObservers() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } ); getDependencies().clear(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void clearDependencies() { getDependencies().forEach( dependency -> { dependency.removeObserver( this ); if ( !dependency.hasObservers() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } ); getDependencies().clear(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void setState() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); setupReadWriteTransaction(); observer.setState( Observer.Flags.STATE_INACTIVE ); assertEquals( observer.getState(), Observer.Flags.STATE_INACTIVE ); assertFalse( observer.getTask().isQueued() ); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); assertFalse( observer.getTask().isQueued() ); observer.setState( Observer.Flags.STATE_STALE ); assertEquals( observer.getState(), Observer.Flags.STATE_STALE ); assertTrue( observer.getTask().isQueued() ); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); observer.setState( Observer.Flags.STATE_STALE ); assertEquals( observer.getState(), Observer.Flags.STATE_STALE ); assertTrue( observer.getTask().isQueued() ); final ObservableValue<?> observableValue1 = Arez.context().observable(); final ObservableValue<?> observableValue2 = Arez.context().observable(); observer.getDependencies().add( observableValue1 ); observer.getDependencies().add( observableValue2 ); observableValue1.rawAddObserver( observer ); observableValue2.rawAddObserver( observer ); assertEquals( observer.getDependencies().size(), 2 ); assertEquals( observableValue1.getObservers().size(), 1 ); assertEquals( observableValue2.getObservers().size(), 1 ); observer.setState( Observer.Flags.STATE_INACTIVE ); assertEquals( observer.getState(), Observer.Flags.STATE_INACTIVE ); assertEquals( observer.getDependencies().size(), 0 ); assertEquals( observableValue1.getObservers().size(), 0 ); assertEquals( observableValue2.getObservers().size(), 0 ); }
void setState( final int state ) { setState( state, true ); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void scheduleReaction() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); setupReadWriteTransaction(); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); assertFalse( observer.getTask().isQueued() ); observer.scheduleReaction(); final ArezContext context = Arez.context(); assertTrue( observer.getTask().isQueued() ); assertEquals( context.getTaskQueue().getOrderedTasks().count(), 1L ); assertTrue( context.getTaskQueue().getOrderedTasks().anyMatch( o -> o == observer.getTask() ) ); observer.scheduleReaction(); assertTrue( observer.getTask().isQueued() ); assertEquals( context.getTaskQueue().getOrderedTasks().count(), 1L ); assertTrue( context.getTaskQueue().getOrderedTasks().anyMatch( o -> o == observer.getTask() ) ); }
void scheduleReaction() { if ( isNotDisposed() ) { if ( Arez.shouldCheckInvariants() ) { invariant( this::isActive, () -> "Arez-0088: Observer named '" + getName() + "' is not active but an attempt has been made " + "to schedule observer." ); } if ( !getTask().isQueued() ) { getContext().scheduleReaction( this ); } } }
Observer extends Node { void scheduleReaction() { if ( isNotDisposed() ) { if ( Arez.shouldCheckInvariants() ) { invariant( this::isActive, () -> "Arez-0088: Observer named '" + getName() + "' is not active but an attempt has been made " + "to schedule observer." ); } if ( !getTask().isQueued() ) { getContext().scheduleReaction( this ); } } } }
Observer extends Node { void scheduleReaction() { if ( isNotDisposed() ) { if ( Arez.shouldCheckInvariants() ) { invariant( this::isActive, () -> "Arez-0088: Observer named '" + getName() + "' is not active but an attempt has been made " + "to schedule observer." ); } if ( !getTask().isQueued() ) { getContext().scheduleReaction( this ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void scheduleReaction() { if ( isNotDisposed() ) { if ( Arez.shouldCheckInvariants() ) { invariant( this::isActive, () -> "Arez-0088: Observer named '" + getName() + "' is not active but an attempt has been made " + "to schedule observer." ); } if ( !getTask().isQueued() ) { getContext().scheduleReaction( this ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void scheduleReaction() { if ( isNotDisposed() ) { if ( Arez.shouldCheckInvariants() ) { invariant( this::isActive, () -> "Arez-0088: Observer named '" + getName() + "' is not active but an attempt has been made " + "to schedule observer." ); } if ( !getTask().isQueued() ) { getContext().scheduleReaction( this ); } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void dispose() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); setCurrentTransaction( observer ); observer.setState( Observer.Flags.STATE_UP_TO_DATE ); Transaction.setTransaction( null ); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); assertTrue( observer.isNotDisposed() ); assertFalse( observer.isDisposed() ); assertFalse( observer.getTask().isDisposed() ); observer.dispose(); assertEquals( observer.getState(), Observer.Flags.STATE_DISPOSED ); assertFalse( observer.isNotDisposed() ); assertTrue( observer.isDisposed() ); assertTrue( observer.getTask().isDisposed() ); final ArezContext context = Arez.context(); final int currentNextTransactionId = context.currentNextTransactionId(); observer.dispose(); assertEquals( context.currentNextTransactionId(), currentNextTransactionId ); }
@Override public void dispose() { if ( isNotDisposedOrDisposing() ) { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( !isComputableValue() ) { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObserverDisposeEvent( asInfo() ) ); } if ( null != _component ) { _component.removeObserver( this ); } else if ( Arez.areRegistriesEnabled() ) { getContext().deregisterObserver( this ); } } if ( null != _computableValue ) { _computableValue.dispose(); } _task.dispose(); markAsDisposed(); } }
Observer extends Node { @Override public void dispose() { if ( isNotDisposedOrDisposing() ) { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( !isComputableValue() ) { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObserverDisposeEvent( asInfo() ) ); } if ( null != _component ) { _component.removeObserver( this ); } else if ( Arez.areRegistriesEnabled() ) { getContext().deregisterObserver( this ); } } if ( null != _computableValue ) { _computableValue.dispose(); } _task.dispose(); markAsDisposed(); } } }
Observer extends Node { @Override public void dispose() { if ( isNotDisposedOrDisposing() ) { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( !isComputableValue() ) { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObserverDisposeEvent( asInfo() ) ); } if ( null != _component ) { _component.removeObserver( this ); } else if ( Arez.areRegistriesEnabled() ) { getContext().deregisterObserver( this ); } } if ( null != _computableValue ) { _computableValue.dispose(); } _task.dispose(); markAsDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { @Override public void dispose() { if ( isNotDisposedOrDisposing() ) { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( !isComputableValue() ) { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObserverDisposeEvent( asInfo() ) ); } if ( null != _component ) { _component.removeObserver( this ); } else if ( Arez.areRegistriesEnabled() ) { getContext().deregisterObserver( this ); } } if ( null != _computableValue ) { _computableValue.dispose(); } _task.dispose(); markAsDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { @Override public void dispose() { if ( isNotDisposedOrDisposing() ) { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); if ( !isComputableValue() ) { if ( willPropagateSpyEvents() ) { reportSpyEvent( new ObserverDisposeEvent( asInfo() ) ); } if ( null != _component ) { _component.removeObserver( this ); } else if ( Arez.areRegistriesEnabled() ) { getContext().deregisterObserver( this ); } } if ( null != _computableValue ) { _computableValue.dispose(); } _task.dispose(); markAsDisposed(); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void markDependenciesLeastStaleObserverAsUpToDate() { final Observer observer = Arez.context().observer( new CountAndObserveProcedure() ); final ObservableValue<?> observableValue1 = Arez.context().observable(); final ObservableValue<?> observableValue2 = Arez.context().observable(); final ObservableValue<?> observableValue3 = Arez.context().observable(); observer.getDependencies().add( observableValue1 ); observer.getDependencies().add( observableValue2 ); observer.getDependencies().add( observableValue3 ); setCurrentTransaction( observer ); observableValue1.addObserver( observer ); observableValue2.addObserver( observer ); observableValue3.addObserver( observer ); observableValue1.setLeastStaleObserverState( Observer.Flags.STATE_UP_TO_DATE ); observableValue2.setLeastStaleObserverState( Observer.Flags.STATE_POSSIBLY_STALE ); observableValue3.setLeastStaleObserverState( Observer.Flags.STATE_STALE ); observer.markDependenciesLeastStaleObserverAsUpToDate(); assertEquals( observableValue1.getLeastStaleObserverState(), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( observableValue2.getLeastStaleObserverState(), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( observableValue3.getLeastStaleObserverState(), Observer.Flags.STATE_UP_TO_DATE ); }
void markDependenciesLeastStaleObserverAsUpToDate() { for ( final ObservableValue<?> dependency : getDependencies() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } }
Observer extends Node { void markDependenciesLeastStaleObserverAsUpToDate() { for ( final ObservableValue<?> dependency : getDependencies() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } }
Observer extends Node { void markDependenciesLeastStaleObserverAsUpToDate() { for ( final ObservableValue<?> dependency : getDependencies() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void markDependenciesLeastStaleObserverAsUpToDate() { for ( final ObservableValue<?> dependency : getDependencies() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void markDependenciesLeastStaleObserverAsUpToDate() { for ( final ObservableValue<?> dependency : getDependencies() ) { dependency.setLeastStaleObserverState( Flags.STATE_UP_TO_DATE ); } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void invokeReaction() { ignoreObserverErrors(); final ArezContext context = Arez.context(); final AtomicInteger errorCount = new AtomicInteger(); context.addObserverErrorHandler( ( observer, error, throwable ) -> errorCount.incrementAndGet() ); final CountAndObserveProcedure observed = new CountAndObserveProcedure(); final Observer observer = new Observer( context, null, ValueUtil.randomString(), observed, null, 0 ); observer.invokeReaction(); assertEquals( observed.getCallCount(), 1 ); assertEquals( errorCount.get(), 0 ); }
void invokeReaction() { if ( isNotDisposed() ) { final long start; if ( willPropagateSpyEvents() ) { start = System.currentTimeMillis(); if ( isComputableValue() ) { reportSpyEvent( new ComputeStartEvent( getComputableValue().asInfo() ) ); } else { reportSpyEvent( new ObserveStartEvent( asInfo() ) ); } } else { start = 0; } Throwable error = null; try { if ( Flags.STATE_UP_TO_DATE != getState() ) { if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); runObserveFunction(); } else { assert null != _onDepsChange; _onDepsChange.call(); } } else if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); } } catch ( final Throwable t ) { error = t; getContext().reportObserverError( this, ObserverError.REACTION_ERROR, t ); } if ( willPropagateSpyEvents() ) { final long duration = System.currentTimeMillis() - start; if ( isComputableValue() ) { final ComputableValue<?> computableValue = getComputableValue(); reportSpyEvent( new ComputeCompleteEvent( computableValue.asInfo(), noReportResults() ? null : computableValue.getValue(), computableValue.getError(), (int) duration ) ); } else { reportSpyEvent( new ObserveCompleteEvent( asInfo(), error, (int) duration ) ); } } } }
Observer extends Node { void invokeReaction() { if ( isNotDisposed() ) { final long start; if ( willPropagateSpyEvents() ) { start = System.currentTimeMillis(); if ( isComputableValue() ) { reportSpyEvent( new ComputeStartEvent( getComputableValue().asInfo() ) ); } else { reportSpyEvent( new ObserveStartEvent( asInfo() ) ); } } else { start = 0; } Throwable error = null; try { if ( Flags.STATE_UP_TO_DATE != getState() ) { if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); runObserveFunction(); } else { assert null != _onDepsChange; _onDepsChange.call(); } } else if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); } } catch ( final Throwable t ) { error = t; getContext().reportObserverError( this, ObserverError.REACTION_ERROR, t ); } if ( willPropagateSpyEvents() ) { final long duration = System.currentTimeMillis() - start; if ( isComputableValue() ) { final ComputableValue<?> computableValue = getComputableValue(); reportSpyEvent( new ComputeCompleteEvent( computableValue.asInfo(), noReportResults() ? null : computableValue.getValue(), computableValue.getError(), (int) duration ) ); } else { reportSpyEvent( new ObserveCompleteEvent( asInfo(), error, (int) duration ) ); } } } } }
Observer extends Node { void invokeReaction() { if ( isNotDisposed() ) { final long start; if ( willPropagateSpyEvents() ) { start = System.currentTimeMillis(); if ( isComputableValue() ) { reportSpyEvent( new ComputeStartEvent( getComputableValue().asInfo() ) ); } else { reportSpyEvent( new ObserveStartEvent( asInfo() ) ); } } else { start = 0; } Throwable error = null; try { if ( Flags.STATE_UP_TO_DATE != getState() ) { if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); runObserveFunction(); } else { assert null != _onDepsChange; _onDepsChange.call(); } } else if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); } } catch ( final Throwable t ) { error = t; getContext().reportObserverError( this, ObserverError.REACTION_ERROR, t ); } if ( willPropagateSpyEvents() ) { final long duration = System.currentTimeMillis() - start; if ( isComputableValue() ) { final ComputableValue<?> computableValue = getComputableValue(); reportSpyEvent( new ComputeCompleteEvent( computableValue.asInfo(), noReportResults() ? null : computableValue.getValue(), computableValue.getError(), (int) duration ) ); } else { reportSpyEvent( new ObserveCompleteEvent( asInfo(), error, (int) duration ) ); } } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void invokeReaction() { if ( isNotDisposed() ) { final long start; if ( willPropagateSpyEvents() ) { start = System.currentTimeMillis(); if ( isComputableValue() ) { reportSpyEvent( new ComputeStartEvent( getComputableValue().asInfo() ) ); } else { reportSpyEvent( new ObserveStartEvent( asInfo() ) ); } } else { start = 0; } Throwable error = null; try { if ( Flags.STATE_UP_TO_DATE != getState() ) { if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); runObserveFunction(); } else { assert null != _onDepsChange; _onDepsChange.call(); } } else if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); } } catch ( final Throwable t ) { error = t; getContext().reportObserverError( this, ObserverError.REACTION_ERROR, t ); } if ( willPropagateSpyEvents() ) { final long duration = System.currentTimeMillis() - start; if ( isComputableValue() ) { final ComputableValue<?> computableValue = getComputableValue(); reportSpyEvent( new ComputeCompleteEvent( computableValue.asInfo(), noReportResults() ? null : computableValue.getValue(), computableValue.getError(), (int) duration ) ); } else { reportSpyEvent( new ObserveCompleteEvent( asInfo(), error, (int) duration ) ); } } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void invokeReaction() { if ( isNotDisposed() ) { final long start; if ( willPropagateSpyEvents() ) { start = System.currentTimeMillis(); if ( isComputableValue() ) { reportSpyEvent( new ComputeStartEvent( getComputableValue().asInfo() ) ); } else { reportSpyEvent( new ObserveStartEvent( asInfo() ) ); } } else { start = 0; } Throwable error = null; try { if ( Flags.STATE_UP_TO_DATE != getState() ) { if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); runObserveFunction(); } else { assert null != _onDepsChange; _onDepsChange.call(); } } else if ( shouldExecuteObserveNext() ) { executeOnDepsChangeNextIfPresent(); } } catch ( final Throwable t ) { error = t; getContext().reportObserverError( this, ObserverError.REACTION_ERROR, t ); } if ( willPropagateSpyEvents() ) { final long duration = System.currentTimeMillis() - start; if ( isComputableValue() ) { final ComputableValue<?> computableValue = getComputableValue(); reportSpyEvent( new ComputeCompleteEvent( computableValue.asInfo(), noReportResults() ? null : computableValue.getValue(), computableValue.getError(), (int) duration ) ); } else { reportSpyEvent( new ObserveCompleteEvent( asInfo(), error, (int) duration ) ); } } } } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void invokeReaction_reactionGeneratesError() { ignoreObserverErrors(); final AtomicInteger errorCount = new AtomicInteger(); final RuntimeException exception = new RuntimeException( "X" ); final ArezContext context = Arez.context(); context.addObserverErrorHandler( ( observer, error, throwable ) -> { errorCount.incrementAndGet(); assertEquals( error, ObserverError.REACTION_ERROR ); assertEquals( throwable, exception ); } ); final CountingProcedure observed = new CountingProcedure() { @Override public void call() throws Throwable { super.call(); throw exception; } }; final Observer observer = context.observer( observed, Observer.Flags.RUN_LATER ); final TestSpyEventHandler handler = TestSpyEventHandler.subscribe(); context.triggerScheduler(); assertEquals( observed.getCallCount(), 1 ); assertEquals( errorCount.get(), 1 ); handler.assertEventCount( 7 ); handler.assertNextEvent( ObserveStartEvent.class, e -> assertEquals( e.getObserver().getName(), observer.getName() ) ); handler.assertNextEvent( ActionStartEvent.class ); handler.assertNextEvent( TransactionStartEvent.class ); handler.assertNextEvent( TransactionCompleteEvent.class ); handler.assertNextEvent( ActionCompleteEvent.class ); handler.assertNextEvent( ObserverErrorEvent.class, e -> { assertEquals( e.getObserver().getName(), observer.getName() ); assertEquals( e.getError(), ObserverError.REACTION_ERROR ); assertEquals( e.getThrowable(), exception ); } ); handler.assertNextEvent( ObserveCompleteEvent.class, e -> { assertEquals( e.getObserver().getName(), observer.getName() ); assertEquals( e.getThrowable(), exception ); assertTrue( e.getDuration() >= 0 ); } ); }
Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ) { this( Arez.areZonesEnabled() ? computableValue.getContext() : null, null, Arez.areNamesEnabled() ? computableValue.getName() : null, computableValue, computableValue::compute, null, flags | ( Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? 0 : Flags.DEACTIVATE_ON_UNOBSERVE ) | Task.Flags.runType( flags, Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? Task.Flags.RUN_NOW : Task.Flags.RUN_LATER ) | ( Arez.shouldEnforceTransactionType() ? Flags.READ_ONLY : 0 ) | Flags.NESTED_ACTIONS_DISALLOWED | Flags.dependencyType( flags ) ); }
Observer extends Node { Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ) { this( Arez.areZonesEnabled() ? computableValue.getContext() : null, null, Arez.areNamesEnabled() ? computableValue.getName() : null, computableValue, computableValue::compute, null, flags | ( Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? 0 : Flags.DEACTIVATE_ON_UNOBSERVE ) | Task.Flags.runType( flags, Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? Task.Flags.RUN_NOW : Task.Flags.RUN_LATER ) | ( Arez.shouldEnforceTransactionType() ? Flags.READ_ONLY : 0 ) | Flags.NESTED_ACTIONS_DISALLOWED | Flags.dependencyType( flags ) ); } }
Observer extends Node { Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ) { this( Arez.areZonesEnabled() ? computableValue.getContext() : null, null, Arez.areNamesEnabled() ? computableValue.getName() : null, computableValue, computableValue::compute, null, flags | ( Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? 0 : Flags.DEACTIVATE_ON_UNOBSERVE ) | Task.Flags.runType( flags, Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? Task.Flags.RUN_NOW : Task.Flags.RUN_LATER ) | ( Arez.shouldEnforceTransactionType() ? Flags.READ_ONLY : 0 ) | Flags.NESTED_ACTIONS_DISALLOWED | Flags.dependencyType( flags ) ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ) { this( Arez.areZonesEnabled() ? computableValue.getContext() : null, null, Arez.areNamesEnabled() ? computableValue.getName() : null, computableValue, computableValue::compute, null, flags | ( Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? 0 : Flags.DEACTIVATE_ON_UNOBSERVE ) | Task.Flags.runType( flags, Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? Task.Flags.RUN_NOW : Task.Flags.RUN_LATER ) | ( Arez.shouldEnforceTransactionType() ? Flags.READ_ONLY : 0 ) | Flags.NESTED_ACTIONS_DISALLOWED | Flags.dependencyType( flags ) ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ) { this( Arez.areZonesEnabled() ? computableValue.getContext() : null, null, Arez.areNamesEnabled() ? computableValue.getName() : null, computableValue, computableValue::compute, null, flags | ( Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? 0 : Flags.DEACTIVATE_ON_UNOBSERVE ) | Task.Flags.runType( flags, Flags.KEEPALIVE == Flags.getScheduleType( flags ) ? Task.Flags.RUN_NOW : Task.Flags.RUN_LATER ) | ( Arez.shouldEnforceTransactionType() ? Flags.READ_ONLY : 0 ) | Flags.NESTED_ACTIONS_DISALLOWED | Flags.dependencyType( flags ) ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void asInfo() { final Observer observer = Arez.context().tracker( ValueUtil::randomString ); final ObserverInfo info = observer.asInfo(); assertEquals( info.getName(), observer.getName() ); }
@SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObserverInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0197: Observer.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObserverInfoImpl( getContext().getSpy(), this ); } return Arez.areSpiesEnabled() ? _info : null; }
Observer extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObserverInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0197: Observer.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObserverInfoImpl( getContext().getSpy(), this ); } return Arez.areSpiesEnabled() ? _info : null; } }
Observer extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObserverInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0197: Observer.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObserverInfoImpl( getContext().getSpy(), this ); } return Arez.areSpiesEnabled() ? _info : null; } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObserverInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0197: Observer.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObserverInfoImpl( getContext().getSpy(), this ); } return Arez.areSpiesEnabled() ? _info : null; } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { @SuppressWarnings( "ConstantConditions" ) @OmitSymbol( unless = "arez.enable_spies" ) @Nonnull ObserverInfo asInfo() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0197: Observer.asInfo() invoked but Arez.areSpiesEnabled() returned false." ); } if ( Arez.areSpiesEnabled() && null == _info ) { _info = new ObserverInfoImpl( getContext().getSpy(), this ); } return Arez.areSpiesEnabled() ? _info : null; } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void reportStale() { final ArezContext context = Arez.context(); final Observer observer = new Observer( context, null, ValueUtil.randomString(), new CountingProcedure(), new CountingProcedure(), Observer.Flags.AREZ_OR_EXTERNAL_DEPENDENCIES ); context.triggerScheduler(); assertEquals( observer.getState(), Observer.Flags.STATE_UP_TO_DATE ); assertFalse( observer.getTask().isQueued() ); context.safeAction( () -> { observer.reportStale(); assertTrue( observer.getTask().isQueued() ); assertEquals( observer.getState(), Observer.Flags.STATE_STALE ); assertEquals( context.getTaskQueue().getOrderedTasks().count(), 1L ); assertTrue( context.getTaskQueue().getOrderedTasks().anyMatch( o -> o == observer.getTask() ) ); } ); }
public void reportStale() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::areExternalDependenciesAllowed, () -> "Arez-0199: Observer.reportStale() invoked on observer named '" + getName() + "' but the observer has not specified AREZ_OR_EXTERNAL_DEPENDENCIES flag." ); apiInvariant( () -> getContext().isTransactionActive(), () -> "Arez-0200: Observer.reportStale() invoked on observer named '" + getName() + "' when there is no active transaction." ); apiInvariant( () -> getContext().getTransaction().isMutation(), () -> "Arez-0201: Observer.reportStale() invoked on observer named '" + getName() + "' when the active transaction '" + getContext().getTransaction().getName() + "' is READ_ONLY rather than READ_WRITE." ); getContext().getTransaction().markTransactionAsUsed(); } setState( Flags.STATE_STALE ); }
Observer extends Node { public void reportStale() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::areExternalDependenciesAllowed, () -> "Arez-0199: Observer.reportStale() invoked on observer named '" + getName() + "' but the observer has not specified AREZ_OR_EXTERNAL_DEPENDENCIES flag." ); apiInvariant( () -> getContext().isTransactionActive(), () -> "Arez-0200: Observer.reportStale() invoked on observer named '" + getName() + "' when there is no active transaction." ); apiInvariant( () -> getContext().getTransaction().isMutation(), () -> "Arez-0201: Observer.reportStale() invoked on observer named '" + getName() + "' when the active transaction '" + getContext().getTransaction().getName() + "' is READ_ONLY rather than READ_WRITE." ); getContext().getTransaction().markTransactionAsUsed(); } setState( Flags.STATE_STALE ); } }
Observer extends Node { public void reportStale() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::areExternalDependenciesAllowed, () -> "Arez-0199: Observer.reportStale() invoked on observer named '" + getName() + "' but the observer has not specified AREZ_OR_EXTERNAL_DEPENDENCIES flag." ); apiInvariant( () -> getContext().isTransactionActive(), () -> "Arez-0200: Observer.reportStale() invoked on observer named '" + getName() + "' when there is no active transaction." ); apiInvariant( () -> getContext().getTransaction().isMutation(), () -> "Arez-0201: Observer.reportStale() invoked on observer named '" + getName() + "' when the active transaction '" + getContext().getTransaction().getName() + "' is READ_ONLY rather than READ_WRITE." ); getContext().getTransaction().markTransactionAsUsed(); } setState( Flags.STATE_STALE ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { public void reportStale() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::areExternalDependenciesAllowed, () -> "Arez-0199: Observer.reportStale() invoked on observer named '" + getName() + "' but the observer has not specified AREZ_OR_EXTERNAL_DEPENDENCIES flag." ); apiInvariant( () -> getContext().isTransactionActive(), () -> "Arez-0200: Observer.reportStale() invoked on observer named '" + getName() + "' when there is no active transaction." ); apiInvariant( () -> getContext().getTransaction().isMutation(), () -> "Arez-0201: Observer.reportStale() invoked on observer named '" + getName() + "' when the active transaction '" + getContext().getTransaction().getName() + "' is READ_ONLY rather than READ_WRITE." ); getContext().getTransaction().markTransactionAsUsed(); } setState( Flags.STATE_STALE ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { public void reportStale() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::areExternalDependenciesAllowed, () -> "Arez-0199: Observer.reportStale() invoked on observer named '" + getName() + "' but the observer has not specified AREZ_OR_EXTERNAL_DEPENDENCIES flag." ); apiInvariant( () -> getContext().isTransactionActive(), () -> "Arez-0200: Observer.reportStale() invoked on observer named '" + getName() + "' when there is no active transaction." ); apiInvariant( () -> getContext().getTransaction().isMutation(), () -> "Arez-0201: Observer.reportStale() invoked on observer named '" + getName() + "' when the active transaction '" + getContext().getTransaction().getName() + "' is READ_ONLY rather than READ_WRITE." ); getContext().getTransaction().markTransactionAsUsed(); } setState( Flags.STATE_STALE ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void isScheduled() { final ArezContext context = Arez.context(); final Spy spy = context.getSpy(); final Observer observer = context.observer( new CountAndObserveProcedure() ); final ObserverInfo info = spy.asObserverInfo( observer ); assertFalse( info.isScheduled() ); observer.getTask().markAsQueued(); assertTrue( info.isScheduled() ); }
@Override public boolean isScheduled() { return _observer.getTask().isQueued(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isScheduled() { return _observer.getTask().isQueued(); } }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isScheduled() { return _observer.getTask().isQueued(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isScheduled() { return _observer.getTask().isQueued(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isScheduled() { return _observer.getTask().isQueued(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
@Test public void schedule() { final ArezContext context = Arez.context(); final CountAndObserveProcedure observed = new CountAndObserveProcedure(); final CountingProcedure onDepsChange = new CountingProcedure(); final Observer observer = new Observer( context, null, ValueUtil.randomString(), observed, onDepsChange, Observer.Flags.RUN_LATER ); context.safeAction( () -> { observer.setState( Observer.Flags.STATE_STALE ); context.getTaskQueue().clear(); }, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); assertFalse( observer.getTask().isQueued() ); assertEquals( observed.getCallCount(), 0 ); assertEquals( onDepsChange.getCallCount(), 0 ); final SchedulerLock schedulerLock = context.pauseScheduler(); observer.schedule(); assertTrue( observer.getTask().isQueued() ); assertEquals( context.getTaskQueue().getOrderedTasks().count(), 1L ); assertTrue( context.getTaskQueue().getOrderedTasks().anyMatch( o -> o == observer.getTask() ) ); schedulerLock.dispose(); assertFalse( observer.getTask().isQueued() ); assertEquals( observed.getCallCount(), 1 ); assertEquals( onDepsChange.getCallCount(), 0 ); }
public void schedule() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::supportsManualSchedule, () -> "Arez-0202: Observer.schedule() invoked on observer named '" + getName() + "' but supportsManualSchedule() returns false." ); } if ( Arez.shouldEnforceTransactionType() && getContext().isTransactionActive() && Arez.shouldCheckInvariants() ) { getContext().getTransaction().markTransactionAsUsed(); } executeObserveNextIfPresent(); scheduleReaction(); getContext().triggerScheduler(); }
Observer extends Node { public void schedule() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::supportsManualSchedule, () -> "Arez-0202: Observer.schedule() invoked on observer named '" + getName() + "' but supportsManualSchedule() returns false." ); } if ( Arez.shouldEnforceTransactionType() && getContext().isTransactionActive() && Arez.shouldCheckInvariants() ) { getContext().getTransaction().markTransactionAsUsed(); } executeObserveNextIfPresent(); scheduleReaction(); getContext().triggerScheduler(); } }
Observer extends Node { public void schedule() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::supportsManualSchedule, () -> "Arez-0202: Observer.schedule() invoked on observer named '" + getName() + "' but supportsManualSchedule() returns false." ); } if ( Arez.shouldEnforceTransactionType() && getContext().isTransactionActive() && Arez.shouldCheckInvariants() ) { getContext().getTransaction().markTransactionAsUsed(); } executeObserveNextIfPresent(); scheduleReaction(); getContext().triggerScheduler(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { public void schedule() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::supportsManualSchedule, () -> "Arez-0202: Observer.schedule() invoked on observer named '" + getName() + "' but supportsManualSchedule() returns false." ); } if ( Arez.shouldEnforceTransactionType() && getContext().isTransactionActive() && Arez.shouldCheckInvariants() ) { getContext().getTransaction().markTransactionAsUsed(); } executeObserveNextIfPresent(); scheduleReaction(); getContext().triggerScheduler(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { public void schedule() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::supportsManualSchedule, () -> "Arez-0202: Observer.schedule() invoked on observer named '" + getName() + "' but supportsManualSchedule() returns false." ); } if ( Arez.shouldEnforceTransactionType() && getContext().isTransactionActive() && Arez.shouldCheckInvariants() ) { getContext().getTransaction().markTransactionAsUsed(); } executeObserveNextIfPresent(); scheduleReaction(); getContext().triggerScheduler(); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void Flags_isActive() { assertFalse( Observer.Flags.isActive( Observer.Flags.STATE_DISPOSED ) ); assertFalse( Observer.Flags.isActive( Observer.Flags.STATE_DISPOSING ) ); assertFalse( Observer.Flags.isActive( Observer.Flags.STATE_INACTIVE ) ); assertTrue( Observer.Flags.isActive( Observer.Flags.STATE_UP_TO_DATE ) ); assertTrue( Observer.Flags.isActive( Observer.Flags.STATE_POSSIBLY_STALE ) ); assertTrue( Observer.Flags.isActive( Observer.Flags.STATE_STALE ) ); }
boolean isActive() { return Flags.isActive( _flags ); }
Observer extends Node { boolean isActive() { return Flags.isActive( _flags ); } }
Observer extends Node { boolean isActive() { return Flags.isActive( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { boolean isActive() { return Flags.isActive( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { boolean isActive() { return Flags.isActive( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void Flags_getState() { assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_DISPOSED ), Observer.Flags.STATE_DISPOSED ); assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_DISPOSING ), Observer.Flags.STATE_DISPOSING ); assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_INACTIVE ), Observer.Flags.STATE_INACTIVE ); assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_UP_TO_DATE ), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_POSSIBLY_STALE ), Observer.Flags.STATE_POSSIBLY_STALE ); assertEquals( Observer.Flags.getState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_STALE ), Observer.Flags.STATE_STALE ); }
int getState() { return Flags.getState( _flags ); }
Observer extends Node { int getState() { return Flags.getState( _flags ); } }
Observer extends Node { int getState() { return Flags.getState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { int getState() { return Flags.getState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { int getState() { return Flags.getState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void Flags_setState() { assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_DISPOSED ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_DISPOSED ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_DISPOSING ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_DISPOSING ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_DISPOSING ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_DISPOSING ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_INACTIVE ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_INACTIVE ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_UP_TO_DATE ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_POSSIBLY_STALE ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_POSSIBLY_STALE ); assertEquals( Observer.Flags.setState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_UP_TO_DATE, Observer.Flags.STATE_STALE ), Observer.Flags.PRIORITY_NORMAL | Observer.Flags.READ_WRITE | Observer.Flags.STATE_STALE ); }
void setState( final int state ) { setState( state, true ); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { void setState( final int state ) { setState( state, true ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void Flags_getLeastStaleObserverState() { assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_DISPOSED ), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_DISPOSING ), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_INACTIVE ), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_UP_TO_DATE ), Observer.Flags.STATE_UP_TO_DATE ); assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_POSSIBLY_STALE ), Observer.Flags.STATE_POSSIBLY_STALE ); assertEquals( Observer.Flags.getLeastStaleObserverState( Observer.Flags.PRIORITY_NORMAL | Observer.Flags.STATE_STALE ), Observer.Flags.STATE_STALE ); }
int getLeastStaleObserverState() { return Flags.getLeastStaleObserverState( _flags ); }
Observer extends Node { int getLeastStaleObserverState() { return Flags.getLeastStaleObserverState( _flags ); } }
Observer extends Node { int getLeastStaleObserverState() { return Flags.getLeastStaleObserverState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); }
Observer extends Node { int getLeastStaleObserverState() { return Flags.getLeastStaleObserverState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
Observer extends Node { int getLeastStaleObserverState() { return Flags.getLeastStaleObserverState( _flags ); } Observer( @Nonnull final ComputableValue<?> computableValue, final int flags ); Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); private Observer( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nullable final ComputableValue<?> computableValue, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, final int flags ); @Override void dispose(); @Override boolean isDisposed(); void reportStale(); void schedule(); }
@Test public void log() { final String message1 = ValueUtil.randomString(); final String message2 = ValueUtil.randomString(); ArezLogger.log( message1, null ); final Throwable throwable = new Throwable(); ArezLogger.log( message2, throwable ); final List<TestLogger.LogEntry> entries = getTestLogger().getEntries(); assertEquals( entries.size(), 2 ); final TestLogger.LogEntry entry1 = entries.get( 0 ); assertEquals( entry1.getMessage(), message1 ); assertNull( entry1.getThrowable() ); final TestLogger.LogEntry entry2 = entries.get( 1 ); assertEquals( entry2.getMessage(), message2 ); assertEquals( entry2.getThrowable(), throwable ); }
static void log( @Nonnull final String message, @Nullable final Throwable throwable ) { c_logger.log( message, throwable ); }
ArezLogger { static void log( @Nonnull final String message, @Nullable final Throwable throwable ) { c_logger.log( message, throwable ); } }
ArezLogger { static void log( @Nonnull final String message, @Nullable final Throwable throwable ) { c_logger.log( message, throwable ); } private ArezLogger(); }
ArezLogger { static void log( @Nonnull final String message, @Nullable final Throwable throwable ) { c_logger.log( message, throwable ); } private ArezLogger(); }
ArezLogger { static void log( @Nonnull final String message, @Nullable final Throwable throwable ) { c_logger.log( message, throwable ); } private ArezLogger(); }
@Test public void toString_NamesDisabled() { ArezTestUtil.disableNames(); final NoSuchEntityException exception = new NoSuchEntityException( 23 ); assertEquals( exception.toString(), "arez.component.NoSuchEntityException" ); }
@Override public String toString() { if ( Arez.areNamesEnabled() ) { return "NoSuchEntityException[id=" + _id + ']'; } else { return super.toString(); } }
NoSuchEntityException extends NoResultException { @Override public String toString() { if ( Arez.areNamesEnabled() ) { return "NoSuchEntityException[id=" + _id + ']'; } else { return super.toString(); } } }
NoSuchEntityException extends NoResultException { @Override public String toString() { if ( Arez.areNamesEnabled() ) { return "NoSuchEntityException[id=" + _id + ']'; } else { return super.toString(); } } NoSuchEntityException( @Nonnull final Object id ); }
NoSuchEntityException extends NoResultException { @Override public String toString() { if ( Arez.areNamesEnabled() ) { return "NoSuchEntityException[id=" + _id + ']'; } else { return super.toString(); } } NoSuchEntityException( @Nonnull final Object id ); @Nonnull Object getId(); @Override String toString(); }
NoSuchEntityException extends NoResultException { @Override public String toString() { if ( Arez.areNamesEnabled() ) { return "NoSuchEntityException[id=" + _id + ']'; } else { return super.toString(); } } NoSuchEntityException( @Nonnull final Object id ); @Nonnull Object getId(); @Override String toString(); }
@Test public void registerLookup_duplicate() { final TypeBasedLocator locator = new TypeBasedLocator(); locator.registerLookup( A.class, i -> new A() ); assertInvariantFailure( () -> locator.registerLookup( A.class, i -> new A() ), "Arez-0188: Attempting to register lookup function for type class arez.component.TypeBasedLocatorTest$A when a function for type already exists." ); }
public <T> void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_findByIdFunctions.containsKey( type ), () -> "Arez-0188: Attempting to register lookup function for type " + type + " when a function for type already exists." ); } _findByIdFunctions.put( type, findByIdFunction ); }
TypeBasedLocator implements Locator { public <T> void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_findByIdFunctions.containsKey( type ), () -> "Arez-0188: Attempting to register lookup function for type " + type + " when a function for type already exists." ); } _findByIdFunctions.put( type, findByIdFunction ); } }
TypeBasedLocator implements Locator { public <T> void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_findByIdFunctions.containsKey( type ), () -> "Arez-0188: Attempting to register lookup function for type " + type + " when a function for type already exists." ); } _findByIdFunctions.put( type, findByIdFunction ); } }
TypeBasedLocator implements Locator { public <T> void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_findByIdFunctions.containsKey( type ), () -> "Arez-0188: Attempting to register lookup function for type " + type + " when a function for type already exists." ); } _findByIdFunctions.put( type, findByIdFunction ); } void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ); @Nullable @Override @SuppressWarnings( "unchecked" ) T findById( @Nonnull final Class<T> type, @Nonnull final Object id ); }
TypeBasedLocator implements Locator { public <T> void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_findByIdFunctions.containsKey( type ), () -> "Arez-0188: Attempting to register lookup function for type " + type + " when a function for type already exists." ); } _findByIdFunctions.put( type, findByIdFunction ); } void registerLookup( @Nonnull final Class<T> type, @Nonnull final Function<Object, T> findByIdFunction ); @Nullable @Override @SuppressWarnings( "unchecked" ) T findById( @Nonnull final Class<T> type, @Nonnull final Object id ); }
@Test public void wrap_when_areRepositoryResultsModifiable_isTrue() { final ArrayList<MyEntity> input = new ArrayList<>(); final MyEntity entity = new MyEntity(); input.add( entity ); final List<MyEntity> output = CollectionsUtil.wrap( input ); assertNotSame( output, input ); assertUnmodifiable( output, MyEntity::new ); assertEquals( output.size(), 1 ); assertEquals( output.get( 0 ), entity ); }
@Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void wrap_List_when_areRepositoryResultsModifiable_isFalse() { final List<MyEntity> input = new ArrayList<>(); final MyEntity entity = new MyEntity(); input.add( entity ); ArezTestUtil.makeCollectionPropertiesModifiable(); final Collection<MyEntity> output = CollectionsUtil.wrap( input ); assertCollectionModifiableVariant( input, entity, output ); }
@Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void isRunning() { final ArezContext context = Arez.context(); final AtomicInteger callCount = new AtomicInteger(); final AtomicReference<ObserverInfo> ref = new AtomicReference<>(); final Observer observer = context.observer( () -> { assertTrue( ref.get().isRunning() ); callCount.incrementAndGet(); observeADependency(); }, Observer.Flags.RUN_LATER ); final ObserverInfo info = context.getSpy().asObserverInfo( observer ); ref.set( info ); assertFalse( info.isRunning() ); assertEquals( callCount.get(), 0 ); context.triggerScheduler(); assertEquals( callCount.get(), 1 ); }
@Override public boolean isRunning() { return _spy.isTransactionActive() && null != getTrackerTransaction(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isRunning() { return _spy.isTransactionActive() && null != getTrackerTransaction(); } }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isRunning() { return _spy.isTransactionActive() && null != getTrackerTransaction(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isRunning() { return _spy.isTransactionActive() && null != getTrackerTransaction(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isRunning() { return _spy.isTransactionActive() && null != getTrackerTransaction(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
@Test public void wrap_Set_when_areRepositoryResultsModifiable_isFalse() { final Set<MyEntity> input = new HashSet<>(); final MyEntity entity = new MyEntity(); input.add( entity ); ArezTestUtil.makeCollectionPropertiesModifiable(); final Collection<MyEntity> output = CollectionsUtil.wrap( input ); assertCollectionModifiableVariant( input, entity, output ); }
@Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void wrap_Collection_when_areRepositoryResultsModifiable_isFalse() { final Collection<MyEntity> input = new HashSet<>(); final MyEntity entity = new MyEntity(); input.add( entity ); ArezTestUtil.makeCollectionPropertiesModifiable(); final Collection<MyEntity> output = CollectionsUtil.wrap( input ); assertCollectionModifiableVariant( input, entity, output ); }
@Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void wrap_Map_when_areRepositoryResultsModifiable_isFalse() { final Map<String, MyEntity> input = new HashMap<>(); final MyEntity entity = new MyEntity(); input.put( ValueUtil.randomString(), entity ); ArezTestUtil.makeCollectionPropertiesModifiable(); final Map<String, MyEntity> output = CollectionsUtil.wrap( input ); assertSame( output, input ); assertEquals( output.size(), 1 ); assertEquals( output.values().iterator().next(), entity ); }
@Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> Collection<T> wrap( @Nonnull final Collection<T> collection ) { return Arez.areCollectionsPropertiesUnmodifiable() ? Collections.unmodifiableCollection( collection ) : collection; } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void asList() { final ArrayList<MyEntity> input = new ArrayList<>(); final MyEntity entity = new MyEntity(); input.add( entity ); final List<MyEntity> output = CollectionsUtil.asList( input.stream() ); assertUnmodifiable( output, MyEntity::new ); assertEquals( output.size(), 1 ); assertEquals( output.get( 0 ), entity ); }
@Nonnull public static <T> List<T> asList( @Nonnull final Stream<T> stream ) { return wrap( stream.collect( Collectors.toList() ) ); }
CollectionsUtil { @Nonnull public static <T> List<T> asList( @Nonnull final Stream<T> stream ) { return wrap( stream.collect( Collectors.toList() ) ); } }
CollectionsUtil { @Nonnull public static <T> List<T> asList( @Nonnull final Stream<T> stream ) { return wrap( stream.collect( Collectors.toList() ) ); } private CollectionsUtil(); }
CollectionsUtil { @Nonnull public static <T> List<T> asList( @Nonnull final Stream<T> stream ) { return wrap( stream.collect( Collectors.toList() ) ); } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
CollectionsUtil { @Nonnull public static <T> List<T> asList( @Nonnull final Stream<T> stream ) { return wrap( stream.collect( Collectors.toList() ) ); } private CollectionsUtil(); @Nonnull static Collection<T> wrap( @Nonnull final Collection<T> collection ); @Nonnull static Set<T> wrap( @Nonnull final Set<T> set ); @Nonnull static Map<K, V> wrap( @Nonnull final Map<K, V> map ); @Nonnull static List<T> wrap( @Nonnull final List<T> list ); @Nonnull static List<T> asList( @Nonnull final Stream<T> stream ); }
@Test public void disposeComputableValue_passedBadArgCounts() { final MemoizeCache<String> cache = new MemoizeCache<>( null, null, ValueUtil.randomString(), args -> args[ 0 ] + "." + args[ 1 ], 2 ); assertInvariantFailure( () -> cache.disposeComputableValue( "a" ), "Arez-0163: MemoizeCache.disposeComputableValue called with 1 argument(s) but expected 2 argument(s)." ); }
@SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
@Test public void disposeComputableValue_noComputableValueCachedForArgs() { final MemoizeCache<String> cache = new MemoizeCache<>( null, null, ValueUtil.randomString(), args -> args[ 0 ] + "." + args[ 1 ], 1 ); assertInvariantFailure( () -> cache.disposeComputableValue( "a" ), "Arez-0193: MemoizeCache.disposeComputableValue called with args [a] but unable to locate corresponding ComputableValue." ); }
@SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
MemoizeCache implements Disposable { @SuppressWarnings( "unchecked" ) void disposeComputableValue( @Nonnull final Object... args ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> args.length == _argCount, () -> "Arez-0163: MemoizeCache.disposeComputableValue called with " + args.length + " argument(s) but expected " + _argCount + " argument(s)." ); } if ( _disposed ) { return; } final Stack<Map<Object, ?>> stack = new Stack<>(); stack.push( _cache ); final int size = args.length - 1; for ( int i = 0; i < size; i++ ) { stack.push( (Map<Object, ?>) stack.peek().get( args[ i ] ) ); } final ComputableValue<T> computableValue = (ComputableValue<T>) stack.peek().remove( args[ size ] ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != computableValue, () -> "Arez-0193: MemoizeCache.disposeComputableValue called with args " + Arrays.asList( args ) + " but unable to locate corresponding ComputableValue." ); } assert null != computableValue; getContext().task( Arez.areNamesEnabled() ? computableValue.getName() + ".dispose" : null, computableValue::dispose, Task.Flags.PRIORITY_HIGHEST | Task.Flags.DISPOSE_ON_COMPLETE | Task.Flags.NO_WRAP_TASK ); while ( stack.size() > 1 ) { final Map<Object, ?> map = stack.pop(); if ( map.isEmpty() ) { stack.peek().remove( args[ stack.size() - 1 ] ); } else { return; } } } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
@Test public void get_passedBadArgCounts() { final MemoizeCache<String> cache = new MemoizeCache<>( null, null, ValueUtil.randomString(), args -> args[ 0 ] + "." + args[ 1 ], 2 ); assertInvariantFailure( () -> cache.get( "a" ), "Arez-0162: MemoizeCache.getComputableValue called with 1 arguments but expected 2 arguments." ); }
public T get( @Nonnull final Object... args ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isNotDisposed, () -> "Arez-0161: MemoizeCache named '" + _name + "' had get() invoked when disposed." ); } return getComputableValue( args ).get(); }
MemoizeCache implements Disposable { public T get( @Nonnull final Object... args ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isNotDisposed, () -> "Arez-0161: MemoizeCache named '" + _name + "' had get() invoked when disposed." ); } return getComputableValue( args ).get(); } }
MemoizeCache implements Disposable { public T get( @Nonnull final Object... args ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isNotDisposed, () -> "Arez-0161: MemoizeCache named '" + _name + "' had get() invoked when disposed." ); } return getComputableValue( args ).get(); } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); }
MemoizeCache implements Disposable { public T get( @Nonnull final Object... args ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isNotDisposed, () -> "Arez-0161: MemoizeCache named '" + _name + "' had get() invoked when disposed." ); } return getComputableValue( args ).get(); } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
MemoizeCache implements Disposable { public T get( @Nonnull final Object... args ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isNotDisposed, () -> "Arez-0161: MemoizeCache named '" + _name + "' had get() invoked when disposed." ); } return getComputableValue( args ).get(); } MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount ); MemoizeCache( @Nullable final ArezContext context, @Nullable final Component component, @Nullable final String name, @Nonnull final Function<T> function, final int argCount, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); T get( @Nonnull final Object... args ); @Override boolean isDisposed(); @Override void dispose(); @SuppressWarnings( "unchecked" ) @Nonnull ComputableValue<T> getComputableValue( @Nonnull final Object... args ); }
@Test public void observe() { ArezTestUtil.disableNativeComponents(); final ArezContext context = Arez.context(); final String name = ValueUtil.randomString(); final ComponentKernel kernel = new ComponentKernel( context, name, 0, null, null, null, null, false, true, false ); kernel.componentConstructed(); kernel.componentReady(); assertTrue( context.safeAction( (SafeFunction<Boolean>) kernel::observe ) ); final AtomicInteger disposedCallCount = new AtomicInteger(); final AtomicInteger notDisposedCallCount = new AtomicInteger(); context.observer( () -> { context.observable().reportObserved(); if ( kernel.isDisposed() ) { disposedCallCount.incrementAndGet(); assertFalse( kernel.observe() ); } else { notDisposedCallCount.incrementAndGet(); assertTrue( kernel.observe() ); } } ); assertEquals( notDisposedCallCount.get(), 1 ); assertEquals( disposedCallCount.get(), 0 ); Disposable.dispose( kernel ); assertFalse( context.safeAction( (SafeFunction<Boolean>) kernel::observe, ActionFlags.NO_VERIFY_ACTION_REQUIRED ) ); assertEquals( notDisposedCallCount.get(), 1 ); assertEquals( disposedCallCount.get(), 1 ); }
@Override public boolean observe() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> null != _disposeOnDeactivate || null != _componentObservable, () -> "Arez-0221: ComponentKernel.observe() invoked on component named '" + getName() + "' but observing is not enabled for component." ); } if ( null != _disposeOnDeactivate ) { return isNotDisposed() ? _disposeOnDeactivate.get() : false; } else { return observe0(); } }
ComponentKernel implements Disposable, ComponentObservable { @Override public boolean observe() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> null != _disposeOnDeactivate || null != _componentObservable, () -> "Arez-0221: ComponentKernel.observe() invoked on component named '" + getName() + "' but observing is not enabled for component." ); } if ( null != _disposeOnDeactivate ) { return isNotDisposed() ? _disposeOnDeactivate.get() : false; } else { return observe0(); } } }
ComponentKernel implements Disposable, ComponentObservable { @Override public boolean observe() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> null != _disposeOnDeactivate || null != _componentObservable, () -> "Arez-0221: ComponentKernel.observe() invoked on component named '" + getName() + "' but observing is not enabled for component." ); } if ( null != _disposeOnDeactivate ) { return isNotDisposed() ? _disposeOnDeactivate.get() : false; } else { return observe0(); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { @Override public boolean observe() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> null != _disposeOnDeactivate || null != _componentObservable, () -> "Arez-0221: ComponentKernel.observe() invoked on component named '" + getName() + "' but observing is not enabled for component." ); } if ( null != _disposeOnDeactivate ) { return isNotDisposed() ? _disposeOnDeactivate.get() : false; } else { return observe0(); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { @Override public boolean observe() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> null != _disposeOnDeactivate || null != _componentObservable, () -> "Arez-0221: ComponentKernel.observe() invoked on component named '" + getName() + "' but observing is not enabled for component." ); } if ( null != _disposeOnDeactivate ) { return isNotDisposed() ? _disposeOnDeactivate.get() : false; } else { return observe0(); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void addOnDisposeListener() { final ArezContext context = Arez.context(); final ComponentKernel kernel = new ComponentKernel( context, "MyType", 1, context.component( "MyType", 1 ), null, null, null, true, false, false ); final String key = ValueUtil.randomString(); final AtomicInteger callCount = new AtomicInteger(); assertEquals( kernel.getOnDisposeListeners().size(), 0 ); assertEquals( callCount.get(), 0 ); kernel.addOnDisposeListener( key, callCount::incrementAndGet ); assertEquals( kernel.getOnDisposeListeners().size(), 1 ); assertEquals( callCount.get(), 0 ); kernel.getOnDisposeListeners().get( key ).call(); assertEquals( kernel.getOnDisposeListeners().size(), 1 ); assertEquals( callCount.get(), 1 ); }
public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void addOnDisposeListener_duplicate() { final ArezContext context = Arez.context(); final ComponentKernel kernel = new ComponentKernel( context, "MyType", 1, context.component( "MyType", 1 ), null, null, null, true, false, false ); final String key = ValueUtil.randomString(); final AtomicInteger callCount = new AtomicInteger(); kernel.addOnDisposeListener( key, callCount::incrementAndGet ); assertInvariantFailure( () -> kernel.addOnDisposeListener( key, callCount::incrementAndGet ), "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); }
public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { public void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ) { assert null != _onDisposeListeners; if ( Arez.shouldCheckApiInvariants() ) { invariant( this::isNotDisposed, () -> "Arez-0170: Attempting to add OnDispose listener but ComponentKernel has been disposed." ); invariant( () -> !_onDisposeListeners.containsKey( key ), () -> "Arez-0166: Attempting to add OnDispose listener with key '" + key + "' but a listener with that key already exists." ); } _onDisposeListeners.put( key, action ); } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void isReadOnly_on_READ_WRITE_observer() { final ArezContext context = Arez.context(); final ObservableValue<Object> observableValue = context.observable(); final Observer observer = context.observer( observableValue::reportObserved, Observer.Flags.READ_WRITE ); assertFalse( observer.asInfo().isReadOnly() ); }
@Override public boolean isReadOnly() { return Arez.shouldEnforceTransactionType() && !_observer.isMutation(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isReadOnly() { return Arez.shouldEnforceTransactionType() && !_observer.isMutation(); } }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isReadOnly() { return Arez.shouldEnforceTransactionType() && !_observer.isMutation(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isReadOnly() { return Arez.shouldEnforceTransactionType() && !_observer.isMutation(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
ObserverInfoImpl implements ObserverInfo { @Override public boolean isReadOnly() { return Arez.shouldEnforceTransactionType() && !_observer.isMutation(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
@Test public void removeOnDisposeListener() { final ArezContext context = Arez.context(); final ComponentKernel kernel = new ComponentKernel( context, "MyType", 1, context.component( "MyType", 1 ), null, null, null, true, false, false ); final String key = ValueUtil.randomString(); final AtomicInteger callCount = new AtomicInteger(); assertEquals( kernel.getOnDisposeListeners().size(), 0 ); kernel.addOnDisposeListener( key, callCount::incrementAndGet ); assertEquals( kernel.getOnDisposeListeners().size(), 1 ); kernel.removeOnDisposeListener( key ); assertEquals( kernel.getOnDisposeListeners().size(), 0 ); }
public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void removeOnDisposeListener_notPresent() { final ArezContext context = Arez.context(); final ComponentKernel kernel = new ComponentKernel( context, "MyType", 1, context.component( "MyType", 1 ), null, null, null, true, false, false ); final String key = ValueUtil.randomString(); assertInvariantFailure( () -> kernel.removeOnDisposeListener( key ), "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); }
public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { public void removeOnDisposeListener( @Nonnull final Object key ) { assert null != _onDisposeListeners; final SafeProcedure removed = _onDisposeListeners.remove( key ); if ( Arez.shouldCheckApiInvariants() ) { invariant( () -> null != removed, () -> "Arez-0167: Attempting to remove OnDispose listener with key '" + key + "' but no such listener exists." ); } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void dispose() { final ArezContext context = Arez.context(); final AtomicReference<ComponentKernel> ref = new AtomicReference<>(); final ComponentKernel kernel = new ComponentKernel( context, "MyType", 1, context.component( "MyType", 1, "MyType@1", () -> ref.get().notifyOnDisposeListeners() ), null, null, null, true, false, false ); ref.set( kernel ); final String key = ValueUtil.randomString(); final AtomicInteger callCount = new AtomicInteger(); assertEquals( callCount.get(), 0 ); kernel.addOnDisposeListener( key, callCount::incrementAndGet ); assertEquals( callCount.get(), 0 ); kernel.dispose(); assertEquals( callCount.get(), 1 ); }
@Override public void dispose() { if ( isNotDisposed() ) { _state = COMPONENT_DISPOSING; if ( Arez.areNativeComponentsEnabled() ) { assert null != _component; _component.dispose(); } else { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); } if ( Arez.shouldCheckApiInvariants() ) { _state = COMPONENT_DISPOSED; } } }
ComponentKernel implements Disposable, ComponentObservable { @Override public void dispose() { if ( isNotDisposed() ) { _state = COMPONENT_DISPOSING; if ( Arez.areNativeComponentsEnabled() ) { assert null != _component; _component.dispose(); } else { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); } if ( Arez.shouldCheckApiInvariants() ) { _state = COMPONENT_DISPOSED; } } } }
ComponentKernel implements Disposable, ComponentObservable { @Override public void dispose() { if ( isNotDisposed() ) { _state = COMPONENT_DISPOSING; if ( Arez.areNativeComponentsEnabled() ) { assert null != _component; _component.dispose(); } else { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); } if ( Arez.shouldCheckApiInvariants() ) { _state = COMPONENT_DISPOSED; } } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); }
ComponentKernel implements Disposable, ComponentObservable { @Override public void dispose() { if ( isNotDisposed() ) { _state = COMPONENT_DISPOSING; if ( Arez.areNativeComponentsEnabled() ) { assert null != _component; _component.dispose(); } else { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); } if ( Arez.shouldCheckApiInvariants() ) { _state = COMPONENT_DISPOSED; } } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
ComponentKernel implements Disposable, ComponentObservable { @Override public void dispose() { if ( isNotDisposed() ) { _state = COMPONENT_DISPOSING; if ( Arez.areNativeComponentsEnabled() ) { assert null != _component; _component.dispose(); } else { getContext().safeAction( Arez.areNamesEnabled() ? getName() + ".dispose" : null, this::performDispose, ActionFlags.NO_VERIFY_ACTION_REQUIRED ); } if ( Arez.shouldCheckApiInvariants() ) { _state = COMPONENT_DISPOSED; } } } ComponentKernel( @Nullable final ArezContext context, @Nullable final String name, final int id, @Nullable final Component component, @Nullable final SafeProcedure preDisposeCallback, @Nullable final SafeProcedure disposeCallback, @Nullable final SafeProcedure postDisposeCallback, final boolean notifyOnDispose, final boolean isComponentObservable, final boolean disposeOnDeactivate ); @Override boolean observe(); @Override void dispose(); @Override boolean isDisposed(); void notifyOnDisposeListeners(); boolean hasBeenInitialized(); boolean hasBeenConstructed(); boolean hasBeenCompleted(); boolean isConstructed(); boolean isComplete(); boolean isReady(); boolean isDisposing(); boolean isActive(); @Nonnull String describeState(); void componentConstructed(); void componentComplete(); void componentReady(); @Nonnull ArezContext getContext(); void safeSetObservable( @Nullable final String name, @Nonnull final SafeProcedure setter ); void setObservable( @Nullable final String name, @Nonnull final Procedure setter ); @Nonnull String getName(); int getId(); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component getComponent(); void addOnDisposeListener( @Nonnull final Object key, @Nonnull final SafeProcedure action ); void removeOnDisposeListener( @Nonnull final Object key ); @Nonnull @Override String toString(); }
@Test public void zoneEnabledConstruction() { ArezTestUtil.enableZones(); final ArezContext context = Arez.context(); final Zone defaultZone = Arez.currentZone(); assertEquals( context.getZone(), defaultZone ); final Zone zone = Arez.createZone(); zone.safeRun( () -> { assertNotEquals( Arez.context().getZone(), defaultZone ); assertEquals( Arez.context().getZone(), zone ); } ); }
@Nonnull Zone getZone() { assert null != _zone; return _zone; }
ArezContext { @Nonnull Zone getZone() { assert null != _zone; return _zone; } }
ArezContext { @Nonnull Zone getZone() { assert null != _zone; return _zone; } ArezContext( @Nullable final Zone zone ); }
ArezContext { @Nonnull Zone getZone() { assert null != _zone; return _zone; } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { @Nonnull Zone getZone() { assert null != _zone; return _zone; } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void generateName() { final ArezContext context = Arez.context(); assertEquals( context.generateName( "ComputableValue", "MyName" ), "MyName" ); context.setNextNodeId( 1 ); assertEquals( context.generateName( "ComputableValue", null ), "ComputableValue@1" ); assertEquals( context.getNextNodeId(), 2 ); ArezTestUtil.disableNames(); assertNull( context.generateName( "ComputableValue", "MyName" ) ); assertNull( context.generateName( "ComputableValue", null ) ); }
@Nullable String generateName( @Nonnull final String prefix, @Nullable final String name ) { return Arez.areNamesEnabled() ? null != name ? name : prefix + "@" + _nextNodeId++ : null; }
ArezContext { @Nullable String generateName( @Nonnull final String prefix, @Nullable final String name ) { return Arez.areNamesEnabled() ? null != name ? name : prefix + "@" + _nextNodeId++ : null; } }
ArezContext { @Nullable String generateName( @Nonnull final String prefix, @Nullable final String name ) { return Arez.areNamesEnabled() ? null != name ? name : prefix + "@" + _nextNodeId++ : null; } ArezContext( @Nullable final Zone zone ); }
ArezContext { @Nullable String generateName( @Nonnull final String prefix, @Nullable final String name ) { return Arez.areNamesEnabled() ? null != name ? name : prefix + "@" + _nextNodeId++ : null; } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { @Nullable String generateName( @Nonnull final String prefix, @Nullable final String name ) { return Arez.areNamesEnabled() ? null != name ? name : prefix + "@" + _nextNodeId++ : null; } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void triggerScheduler() { final ArezContext context = Arez.context(); final AtomicInteger callCount = new AtomicInteger(); context.observer( () -> { observeADependency(); callCount.incrementAndGet(); }, Observer.Flags.RUN_LATER ); assertEquals( callCount.get(), 0 ); context.triggerScheduler(); assertEquals( callCount.get(), 1 ); }
public void triggerScheduler() { if ( isSchedulerEnabled() && !isSchedulerPaused() ) { if ( !_schedulerActive ) { _schedulerActive = true; try { if ( Arez.isTaskInterceptorEnabled() && null != _taskInterceptor ) { assert null != _taskExecuteAction; do { _taskInterceptor.executeTasks( _taskExecuteAction ); } while ( _executor.getPendingTaskCount() > 0 ); } else { _executor.runTasks(); } } finally { _schedulerActive = false; } } } }
ArezContext { public void triggerScheduler() { if ( isSchedulerEnabled() && !isSchedulerPaused() ) { if ( !_schedulerActive ) { _schedulerActive = true; try { if ( Arez.isTaskInterceptorEnabled() && null != _taskInterceptor ) { assert null != _taskExecuteAction; do { _taskInterceptor.executeTasks( _taskExecuteAction ); } while ( _executor.getPendingTaskCount() > 0 ); } else { _executor.runTasks(); } } finally { _schedulerActive = false; } } } } }
ArezContext { public void triggerScheduler() { if ( isSchedulerEnabled() && !isSchedulerPaused() ) { if ( !_schedulerActive ) { _schedulerActive = true; try { if ( Arez.isTaskInterceptorEnabled() && null != _taskInterceptor ) { assert null != _taskExecuteAction; do { _taskInterceptor.executeTasks( _taskExecuteAction ); } while ( _executor.getPendingTaskCount() > 0 ); } else { _executor.runTasks(); } } finally { _schedulerActive = false; } } } } ArezContext( @Nullable final Zone zone ); }
ArezContext { public void triggerScheduler() { if ( isSchedulerEnabled() && !isSchedulerPaused() ) { if ( !_schedulerActive ) { _schedulerActive = true; try { if ( Arez.isTaskInterceptorEnabled() && null != _taskInterceptor ) { assert null != _taskExecuteAction; do { _taskInterceptor.executeTasks( _taskExecuteAction ); } while ( _executor.getPendingTaskCount() > 0 ); } else { _executor.runTasks(); } } finally { _schedulerActive = false; } } } } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { public void triggerScheduler() { if ( isSchedulerEnabled() && !isSchedulerPaused() ) { if ( !_schedulerActive ) { _schedulerActive = true; try { if ( Arez.isTaskInterceptorEnabled() && null != _taskInterceptor ) { assert null != _taskExecuteAction; do { _taskInterceptor.executeTasks( _taskExecuteAction ); } while ( _executor.getPendingTaskCount() > 0 ); } else { _executor.runTasks(); } } finally { _schedulerActive = false; } } } } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void isReadOnlyTransactionActive() throws Throwable { final ArezContext context = Arez.context(); assertFalse( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); context.action( () -> { assertTrue( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); observeADependency(); context.action( () -> { assertTrue( context.isTransactionActive() ); assertTrue( context.isReadOnlyTransactionActive() ); observeADependency(); }, ActionFlags.READ_ONLY ); } ); assertFalse( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); }
public boolean isReadOnlyTransactionActive() { return Transaction.isTransactionActive( this ) && ( !Arez.shouldEnforceTransactionType() || !Transaction.current().isMutation() ); }
ArezContext { public boolean isReadOnlyTransactionActive() { return Transaction.isTransactionActive( this ) && ( !Arez.shouldEnforceTransactionType() || !Transaction.current().isMutation() ); } }
ArezContext { public boolean isReadOnlyTransactionActive() { return Transaction.isTransactionActive( this ) && ( !Arez.shouldEnforceTransactionType() || !Transaction.current().isMutation() ); } ArezContext( @Nullable final Zone zone ); }
ArezContext { public boolean isReadOnlyTransactionActive() { return Transaction.isTransactionActive( this ) && ( !Arez.shouldEnforceTransactionType() || !Transaction.current().isMutation() ); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { public boolean isReadOnlyTransactionActive() { return Transaction.isTransactionActive( this ) && ( !Arez.shouldEnforceTransactionType() || !Transaction.current().isMutation() ); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void isTrackingTransactionActive() throws Throwable { final ArezContext context = Arez.context(); assertFalse( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); assertFalse( context.isReadWriteTransactionActive() ); assertFalse( context.isTrackingTransactionActive() ); context.action( () -> { assertTrue( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); assertTrue( context.isReadWriteTransactionActive() ); observeADependency(); } ); final Observer tracker = context.tracker( () -> assertFalse( context.isTrackingTransactionActive() ) ); context.observe( tracker, () -> { observeADependency(); assertTrue( context.isTransactionActive() ); assertTrue( context.isReadOnlyTransactionActive() ); assertFalse( context.isReadWriteTransactionActive() ); assertTrue( context.isTrackingTransactionActive() ); } ); assertFalse( context.isTransactionActive() ); assertFalse( context.isReadOnlyTransactionActive() ); assertFalse( context.isReadWriteTransactionActive() ); assertFalse( context.isTrackingTransactionActive() ); }
public boolean isTrackingTransactionActive() { return Transaction.isTransactionActive( this ) && null != Transaction.current().getTracker(); }
ArezContext { public boolean isTrackingTransactionActive() { return Transaction.isTransactionActive( this ) && null != Transaction.current().getTracker(); } }
ArezContext { public boolean isTrackingTransactionActive() { return Transaction.isTransactionActive( this ) && null != Transaction.current().getTracker(); } ArezContext( @Nullable final Zone zone ); }
ArezContext { public boolean isTrackingTransactionActive() { return Transaction.isTransactionActive( this ) && null != Transaction.current().getTracker(); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { public boolean isTrackingTransactionActive() { return Transaction.isTransactionActive( this ) && null != Transaction.current().getTracker(); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@SuppressWarnings( "MagicConstant" ) @Test public void verifyActionFlags() { final Procedure executable = () -> { }; assertInvariantFailure( () -> Arez.context().action( executable, Observer.Flags.DEACTIVATE_ON_UNOBSERVE ), "Arez-0212: Flags passed to action 'Action@1' include some " + "unexpected flags set: " + Observer.Flags.DEACTIVATE_ON_UNOBSERVE ); }
private void verifyActionFlags( @Nullable final String name, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ) { if ( Arez.shouldCheckApiInvariants() ) { final int nonActionFlags = flags & ~ActionFlags.CONFIG_FLAGS_MASK; apiInvariant( () -> 0 == nonActionFlags, () -> "Arez-0212: Flags passed to action '" + name + "' include some unexpected " + "flags set: " + nonActionFlags ); apiInvariant( () -> !Arez.shouldEnforceTransactionType() || Transaction.Flags.isTransactionModeValid( Transaction.Flags.transactionMode( flags ) | flags ), () -> "Arez-0126: Flags passed to action '" + name + "' include both READ_ONLY and READ_WRITE." ); apiInvariant( () -> ActionFlags.isVerifyActionRuleValid( flags | ActionFlags.verifyActionRule( flags ) ), () -> "Arez-0127: Flags passed to action '" + name + "' include both VERIFY_ACTION_REQUIRED " + "and NO_VERIFY_ACTION_REQUIRED." ); } }
ArezContext { private void verifyActionFlags( @Nullable final String name, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ) { if ( Arez.shouldCheckApiInvariants() ) { final int nonActionFlags = flags & ~ActionFlags.CONFIG_FLAGS_MASK; apiInvariant( () -> 0 == nonActionFlags, () -> "Arez-0212: Flags passed to action '" + name + "' include some unexpected " + "flags set: " + nonActionFlags ); apiInvariant( () -> !Arez.shouldEnforceTransactionType() || Transaction.Flags.isTransactionModeValid( Transaction.Flags.transactionMode( flags ) | flags ), () -> "Arez-0126: Flags passed to action '" + name + "' include both READ_ONLY and READ_WRITE." ); apiInvariant( () -> ActionFlags.isVerifyActionRuleValid( flags | ActionFlags.verifyActionRule( flags ) ), () -> "Arez-0127: Flags passed to action '" + name + "' include both VERIFY_ACTION_REQUIRED " + "and NO_VERIFY_ACTION_REQUIRED." ); } } }
ArezContext { private void verifyActionFlags( @Nullable final String name, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ) { if ( Arez.shouldCheckApiInvariants() ) { final int nonActionFlags = flags & ~ActionFlags.CONFIG_FLAGS_MASK; apiInvariant( () -> 0 == nonActionFlags, () -> "Arez-0212: Flags passed to action '" + name + "' include some unexpected " + "flags set: " + nonActionFlags ); apiInvariant( () -> !Arez.shouldEnforceTransactionType() || Transaction.Flags.isTransactionModeValid( Transaction.Flags.transactionMode( flags ) | flags ), () -> "Arez-0126: Flags passed to action '" + name + "' include both READ_ONLY and READ_WRITE." ); apiInvariant( () -> ActionFlags.isVerifyActionRuleValid( flags | ActionFlags.verifyActionRule( flags ) ), () -> "Arez-0127: Flags passed to action '" + name + "' include both VERIFY_ACTION_REQUIRED " + "and NO_VERIFY_ACTION_REQUIRED." ); } } ArezContext( @Nullable final Zone zone ); }
ArezContext { private void verifyActionFlags( @Nullable final String name, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ) { if ( Arez.shouldCheckApiInvariants() ) { final int nonActionFlags = flags & ~ActionFlags.CONFIG_FLAGS_MASK; apiInvariant( () -> 0 == nonActionFlags, () -> "Arez-0212: Flags passed to action '" + name + "' include some unexpected " + "flags set: " + nonActionFlags ); apiInvariant( () -> !Arez.shouldEnforceTransactionType() || Transaction.Flags.isTransactionModeValid( Transaction.Flags.transactionMode( flags ) | flags ), () -> "Arez-0126: Flags passed to action '" + name + "' include both READ_ONLY and READ_WRITE." ); apiInvariant( () -> ActionFlags.isVerifyActionRuleValid( flags | ActionFlags.verifyActionRule( flags ) ), () -> "Arez-0127: Flags passed to action '" + name + "' include both VERIFY_ACTION_REQUIRED " + "and NO_VERIFY_ACTION_REQUIRED." ); } } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { private void verifyActionFlags( @Nullable final String name, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ) { if ( Arez.shouldCheckApiInvariants() ) { final int nonActionFlags = flags & ~ActionFlags.CONFIG_FLAGS_MASK; apiInvariant( () -> 0 == nonActionFlags, () -> "Arez-0212: Flags passed to action '" + name + "' include some unexpected " + "flags set: " + nonActionFlags ); apiInvariant( () -> !Arez.shouldEnforceTransactionType() || Transaction.Flags.isTransactionModeValid( Transaction.Flags.transactionMode( flags ) | flags ), () -> "Arez-0126: Flags passed to action '" + name + "' include both READ_ONLY and READ_WRITE." ); apiInvariant( () -> ActionFlags.isVerifyActionRuleValid( flags | ActionFlags.verifyActionRule( flags ) ), () -> "Arez-0127: Flags passed to action '" + name + "' include both VERIFY_ACTION_REQUIRED " + "and NO_VERIFY_ACTION_REQUIRED." ); } } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void verifyActionFlags_badTransactionFlags() { final Procedure executable = () -> { }; assertInvariantFailure( () -> Arez.context() .action( executable, ActionFlags.READ_ONLY | ActionFlags.READ_WRITE ), "Arez-0126: Flags passed to action 'Action@1' include both READ_ONLY and READ_WRITE." ); }
public <T> T action( @Nonnull final Function<T> executable ) throws Throwable { return action( executable, 0 ); }
ArezContext { public <T> T action( @Nonnull final Function<T> executable ) throws Throwable { return action( executable, 0 ); } }
ArezContext { public <T> T action( @Nonnull final Function<T> executable ) throws Throwable { return action( executable, 0 ); } ArezContext( @Nullable final Zone zone ); }
ArezContext { public <T> T action( @Nonnull final Function<T> executable ) throws Throwable { return action( executable, 0 ); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
ArezContext { public <T> T action( @Nonnull final Function<T> executable ) throws Throwable { return action( executable, 0 ); } ArezContext( @Nullable final Zone zone ); @OmitSymbol( unless = "arez.enable_native_components" ) boolean isComponentPresent( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose ); @OmitSymbol( unless = "arez.enable_native_components" ) @Nonnull Component component( @Nonnull final String type, @Nonnull final Object id, @Nullable final String name, @Nullable final SafeProcedure preDispose, @Nullable final SafeProcedure postDispose ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate ); @Nonnull ComputableValue<T> computable( @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull ComputableValue<T> computable( @Nullable final Component component, @Nullable final String name, @Nonnull final SafeFunction<T> function, @Nullable final Procedure onActivate, @Nullable final Procedure onDeactivate, @MagicConstant( flagsFromClass = ComputableValue.Flags.class ) final int flags ); @Nonnull Observer observer( @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure observe, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange ); @Nonnull Observer observer( @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer observer( @Nullable final Component component, @Nullable final String name, @Nullable final Procedure observe, @Nullable final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange ); @Nonnull Observer tracker( @Nullable final Component component, @Nullable final String name, @Nonnull final Procedure onDepsChange, @MagicConstant( flagsFromClass = Observer.Flags.class ) final int flags ); @Nonnull ObservableValue<T> observable(); @Nonnull ObservableValue<T> observable( @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor ); @Nonnull ObservableValue<T> observable( @Nullable final Component component, @Nullable final String name, @Nullable final PropertyAccessor<T> accessor, @Nullable final PropertyMutator<T> mutator ); @Nonnull Task task( @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work ); @Nonnull Task task( @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); @Nonnull Task task( @Nullable final String name, @Nonnull final SafeProcedure work, @MagicConstant( flagsFromClass = Task.Flags.class ) final int flags ); boolean isSchedulerActive(); boolean isTransactionActive(); boolean isTrackingTransactionActive(); boolean isReadWriteTransactionActive(); boolean isReadOnlyTransactionActive(); boolean isSchedulerPaused(); @Nonnull SchedulerLock pauseScheduler(); @OmitSymbol( unless = "arez.enable_task_interceptor" ) void setTaskInterceptor( @Nullable final TaskInterceptor taskInterceptor ); void triggerScheduler(); T action( @Nonnull final Function<T> executable ); T action( @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T action( @Nullable final String name, @Nonnull final Function<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe ); T observe( @Nonnull final Observer observer, @Nonnull final Function<T> observe, @Nullable final Object[] parameters ); T safeAction( @Nonnull final SafeFunction<T> executable ); T safeAction( @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); T safeAction( @Nullable final String name, @Nonnull final SafeFunction<T> executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe ); T safeObserve( @Nonnull final Observer observer, @Nonnull final SafeFunction<T> observe, @Nullable final Object[] parameters ); void action( @Nonnull final Procedure executable ); void action( @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void action( @Nullable final String name, @Nonnull final Procedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe ); void observe( @Nonnull final Observer observer, @Nonnull final Procedure observe, @Nullable final Object[] parameters ); void safeAction( @Nonnull final SafeProcedure executable ); void safeAction( @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags ); void safeAction( @Nullable final String name, @Nonnull final SafeProcedure executable, @MagicConstant( flagsFromClass = ActionFlags.class ) final int flags, @Nullable final Object[] parameters ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe ); void safeObserve( @Nonnull final Observer observer, @Nonnull final SafeProcedure observe, @Nullable final Object[] parameters ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Disposable registerLocator( @Nonnull final Locator locator ); @OmitSymbol( unless = "arez.enable_references" ) @Nonnull Locator locator(); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @OmitSymbol( unless = "arez.enable_observer_error_handlers" ) void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ); @Nonnull Spy getSpy(); }
@Test public void getDependencies() { final ArezContext context = Arez.context(); final Spy spy = context.getSpy(); final ObservableValue<Object> observable = context.observable(); final Observer observer = context.observer( observable::reportObserved ); final List<ObservableValueInfo> dependencies = spy.asObserverInfo( observer ).getDependencies(); assertEquals( dependencies.size(), 1 ); assertEquals( dependencies.get( 0 ).getName(), observable.getName() ); assertUnmodifiable( dependencies ); }
@Nonnull @Override public List<ObservableValueInfo> getDependencies() { final Transaction transaction = _spy.isTransactionActive() ? getTrackerTransaction() : null; if ( null != transaction ) { final List<ObservableValue<?>> observableValues = transaction.getObservableValues(); if ( null == observableValues ) { return Collections.emptyList(); } else { final List<ObservableValue<?>> list = observableValues.stream().distinct().collect( Collectors.toList() ); return ObservableValueInfoImpl.asUnmodifiableInfos( list ); } } else { return ObservableValueInfoImpl.asUnmodifiableInfos( _observer.getDependencies() ); } }
ObserverInfoImpl implements ObserverInfo { @Nonnull @Override public List<ObservableValueInfo> getDependencies() { final Transaction transaction = _spy.isTransactionActive() ? getTrackerTransaction() : null; if ( null != transaction ) { final List<ObservableValue<?>> observableValues = transaction.getObservableValues(); if ( null == observableValues ) { return Collections.emptyList(); } else { final List<ObservableValue<?>> list = observableValues.stream().distinct().collect( Collectors.toList() ); return ObservableValueInfoImpl.asUnmodifiableInfos( list ); } } else { return ObservableValueInfoImpl.asUnmodifiableInfos( _observer.getDependencies() ); } } }
ObserverInfoImpl implements ObserverInfo { @Nonnull @Override public List<ObservableValueInfo> getDependencies() { final Transaction transaction = _spy.isTransactionActive() ? getTrackerTransaction() : null; if ( null != transaction ) { final List<ObservableValue<?>> observableValues = transaction.getObservableValues(); if ( null == observableValues ) { return Collections.emptyList(); } else { final List<ObservableValue<?>> list = observableValues.stream().distinct().collect( Collectors.toList() ); return ObservableValueInfoImpl.asUnmodifiableInfos( list ); } } else { return ObservableValueInfoImpl.asUnmodifiableInfos( _observer.getDependencies() ); } } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); }
ObserverInfoImpl implements ObserverInfo { @Nonnull @Override public List<ObservableValueInfo> getDependencies() { final Transaction transaction = _spy.isTransactionActive() ? getTrackerTransaction() : null; if ( null != transaction ) { final List<ObservableValue<?>> observableValues = transaction.getObservableValues(); if ( null == observableValues ) { return Collections.emptyList(); } else { final List<ObservableValue<?>> list = observableValues.stream().distinct().collect( Collectors.toList() ); return ObservableValueInfoImpl.asUnmodifiableInfos( list ); } } else { return ObservableValueInfoImpl.asUnmodifiableInfos( _observer.getDependencies() ); } } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
ObserverInfoImpl implements ObserverInfo { @Nonnull @Override public List<ObservableValueInfo> getDependencies() { final Transaction transaction = _spy.isTransactionActive() ? getTrackerTransaction() : null; if ( null != transaction ) { final List<ObservableValue<?>> observableValues = transaction.getObservableValues(); if ( null == observableValues ) { return Collections.emptyList(); } else { final List<ObservableValue<?>> list = observableValues.stream().distinct().collect( Collectors.toList() ); return ObservableValueInfoImpl.asUnmodifiableInfos( list ); } } else { return ObservableValueInfoImpl.asUnmodifiableInfos( _observer.getDependencies() ); } } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isScheduled(); @Override boolean isComputableValue(); @Override boolean isReadOnly(); @Nonnull @Override Priority getPriority(); @Nonnull @Override ComputableValueInfo asComputableValue(); @Nonnull @Override List<ObservableValueInfo> getDependencies(); @Nullable @Override ComponentInfo getComponent(); @Override boolean isDisposed(); @Override String toString(); @Override boolean equals( final Object o ); @Override int hashCode(); }
@Test public void writeToFile() throws IOException { Path fileToWrite = Files.createTempFile(null, null); fileToWrite.toFile().deleteOnExit(); RefactoringsWriters.getJMoveWriter().writeRefactoringsInTextForm(REFACTORINGS_TO_WRITE, fileToWrite); checkWrittenRefactorings(fileToWrite.toFile()); }
@Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } @Override String getName(); @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } @Override String getName(); @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); }
@Test public void testCorrect2() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "correctTest2.txt"); validator.validate(entries); assertEquals(1, result.validLines().size()); assertEquals(0, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testCorrect3() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "correctTest3.txt"); validator.validate(entries); assertEquals(1, result.validLines().size()); assertEquals(0, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testIncorrectTimestamp() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest1.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testIncorrectUsedId() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest2.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testIncorrectSessionId() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest3.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testBothEmpty() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest4.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testRejectedMissing() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest5.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testIncorrectJsonInPayload() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest6.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testEmptyPayload() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "incorrectTest7.txt"); validator.validate(entries); assertEquals(0, result.validLines().size()); assertEquals(1, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void writeToOutputStream() throws IOException { Path fileToWrite = Files.createTempFile(null, null); fileToWrite.toFile().deleteOnExit(); RefactoringsWriters.getJMoveWriter().writeRefactoringsInTextForm(REFACTORINGS_TO_WRITE, new FileOutputStream(fileToWrite.toFile())); checkWrittenRefactorings(fileToWrite.toFile()); }
@Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } @Override String getName(); @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); }
JMoveWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, getRefactoringsInJMoveFormat(refactorings)); } @Override String getName(); @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); }
@Test public void writeToFile() throws IOException { Path fileToWrite = Files.createTempFile(null, null); fileToWrite.toFile().deleteOnExit(); RefactoringsWriters.getJBWriter().writeRefactoringsInTextForm(REFACTORINGS_TO_WRITE, fileToWrite); checkWrittenRefactorings(fileToWrite.toFile()); }
@Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); @Override String getName(); }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); @Override String getName(); }
@Test public void writeToOutputStream() throws IOException { Path fileToWrite = Files.createTempFile(null, null); fileToWrite.toFile().deleteOnExit(); RefactoringsWriters.getJBWriter().writeRefactoringsInTextForm(REFACTORINGS_TO_WRITE, new FileOutputStream(fileToWrite.toFile())); checkWrittenRefactorings(fileToWrite.toFile()); }
@Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); @Override String getName(); }
JBWriter implements RefactoringsWriter { @Override public void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath) throws IOException { Files.write(refactoringsPath, Collections.singleton(JSON_CONVERTER.toJson(refactorings))); } @Override void write(List<MoveMethodRefactoring> refactorings, Path refactoringsPath); @Override void write(List<MoveMethodRefactoring> refactorings, OutputStream outputStream); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, Path refactoringsPath); @Override void writeRefactoringsInTextForm(List<RefactoringTextRepresentation> refactorings, OutputStream outputStream); @Override String getName(); }
@Test public void readFromFile() throws IOException { checkReadRefactorings(RefactoringsReaders.getJBReader().read(REFACTORINGS_PATH)); }
@Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
@Test public void readFromInputStream() throws IOException { checkReadRefactorings(RefactoringsReaders.getJBReader().read(new FileInputStream(REFACTORINGS_PATH.toFile()))); }
@Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
JBReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { try (BufferedReader reader = Files.newBufferedReader(refactoringsPath)) { Type listType = new TypeToken<List<JBRefactoringTextRepresentation>>(){}.getType(); return JSON_CONVERTER.fromJson(reader, listType); } } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
@Test public void readFromFile() throws IOException { checkReadRefactorings(RefactoringsReaders.getJMoveReader().read(REFACTORINGS_PATH)); }
@Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
@Test public void readFromInputStream() throws IOException { checkReadRefactorings(RefactoringsReaders.getJMoveReader().read(new FileInputStream(REFACTORINGS_PATH.toFile()))); }
@Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
JMoveReader implements RefactoringsReader { @Override public List<RefactoringTextRepresentation> read(Path refactoringsPath) throws IOException { return parseLines(Files.lines(refactoringsPath)); } @Override List<RefactoringTextRepresentation> read(Path refactoringsPath); @Override List<RefactoringTextRepresentation> read(InputStream inputStream); @Override String getName(); }
@Test public void addResult() { CombinedEvaluationResult combinedEvaluationResult = new CombinedEvaluationResult(TEST_ALGORITHM); assertEquals(0, combinedEvaluationResult.getNumberOfGood()); assertEquals(0, combinedEvaluationResult.getNumberOfFoundGood()); assertEquals(0, combinedEvaluationResult.getNumberOfBad()); assertEquals(0, combinedEvaluationResult.getNumberOfFoundBad()); assertEquals(0, combinedEvaluationResult.getNumberOfFoundOthers()); assertEquals(Collections.emptyList(), combinedEvaluationResult.getErrors()); ProjectEvaluationResult projectEvaluationResult1 = mock(ProjectEvaluationResult.class); when(projectEvaluationResult1.getAlgorithm()).thenReturn(TEST_ALGORITHM); when(projectEvaluationResult1.getNumberOfGood()).thenReturn(10); when(projectEvaluationResult1.getNumberOfFoundGood()).thenReturn(4); when(projectEvaluationResult1.getNumberOfBad()).thenReturn(6); when(projectEvaluationResult1.getNumberOfFoundBad()).thenReturn(2); when(projectEvaluationResult1.getNumberOfFoundOthers()).thenReturn(12); when(projectEvaluationResult1.getErrors()).thenReturn(Arrays.asList( 1 - 0.5, 1 - 0.9, 1 - 0.7, 1 - 0.85, 0.8 - 0.0, 0.2 - 0 )); combinedEvaluationResult.addResult(projectEvaluationResult1); assertEquals(10, combinedEvaluationResult.getNumberOfGood()); assertEquals(4, combinedEvaluationResult.getNumberOfFoundGood()); assertEquals(6, combinedEvaluationResult.getNumberOfBad()); assertEquals(2, combinedEvaluationResult.getNumberOfFoundBad()); assertEquals(12, combinedEvaluationResult.getNumberOfFoundOthers()); assertEquals(Arrays.asList( 1 - 0.5, 1 - 0.9, 1 - 0.7, 1 - 0.85, 0.8 - 0.0, 0.2 - 0), combinedEvaluationResult.getErrors()); assertEquals((double) 4 / 6, combinedEvaluationResult.getGoodPrecision(), 0); assertEquals((double) 4 / 10, combinedEvaluationResult.getGoodRecall(), 0); assertEquals((double) (6 - 2) / (10 + 6 - 4 - 2), combinedEvaluationResult.getBadPrecision(), 0); assertEquals((double) (6 - 2) / 6, combinedEvaluationResult.getBadRecall(), 0); assertEquals((pow(1 - 0.5, 2) + pow(1 - 0.9, 2) + pow(1 - 0.7, 2) + pow(1 - 0.85, 2) + pow(0.8 - 0.0, 2) + pow(0.2 - 0, 2)) / 6, combinedEvaluationResult.getMSE(), 0); assertEquals((1 - 0.5 + 1 - 0.9 + 1 - 0.7 + 1 - 0.85 + 0.8 - 0.0 + 0.2 - 0) / 6, combinedEvaluationResult.getME(), 0); ProjectEvaluationResult projectEvaluationResult2 = mock(ProjectEvaluationResult.class); when(projectEvaluationResult2.getAlgorithm()).thenReturn(TEST_ALGORITHM); when(projectEvaluationResult2.getNumberOfGood()).thenReturn(14); when(projectEvaluationResult2.getNumberOfFoundGood()).thenReturn(2); when(projectEvaluationResult2.getNumberOfBad()).thenReturn(10); when(projectEvaluationResult2.getNumberOfFoundBad()).thenReturn(1); when(projectEvaluationResult2.getNumberOfFoundOthers()).thenReturn(24); when(projectEvaluationResult2.getErrors()).thenReturn(Arrays.asList( 1 - 0.2, 1 - 0.1, 0.9 - 0.0 )); combinedEvaluationResult.addResult(projectEvaluationResult2); assertEquals(24, combinedEvaluationResult.getNumberOfGood()); assertEquals(6, combinedEvaluationResult.getNumberOfFoundGood()); assertEquals(16, combinedEvaluationResult.getNumberOfBad()); assertEquals(3, combinedEvaluationResult.getNumberOfFoundBad()); assertEquals(36, combinedEvaluationResult.getNumberOfFoundOthers()); assertEquals(Arrays.asList( 1 - 0.5, 1 - 0.9, 1 - 0.7, 1 - 0.85, 0.8 - 0.0, 0.2 - 0, 1 - 0.2, 1 - 0.1, 0.9 - 0.0), combinedEvaluationResult.getErrors()); assertEquals((double) 6 / 9, combinedEvaluationResult.getGoodPrecision(), 0); assertEquals((double) 6 / 24, combinedEvaluationResult.getGoodRecall(), 0); assertEquals((double) (16 - 3) / (24 + 16 - 6 - 3), combinedEvaluationResult.getBadPrecision(), 0); assertEquals((double) (16 - 3) / 16, combinedEvaluationResult.getBadRecall(), 0); assertEquals((pow(1 - 0.5, 2) + pow(1 - 0.9, 2) + pow(1 - 0.7, 2) + pow(1 - 0.85, 2) + pow(0.8 - 0.0, 2) + pow(0.2 - 0, 2) + pow(1 - 0.2, 2) + pow(1 - 0.1, 2) + pow(0.9 - 0.0, 2)) / 9, combinedEvaluationResult.getMSE(), 0); assertEquals((1 - 0.5 + 1 - 0.9 + 1 - 0.7 + 1 - 0.85 + 0.8 - 0.0 + 0.2 - 0 + 1 - 0.2 + 1 - 0.1 + 0.9 - 0.0) / 9, combinedEvaluationResult.getME(), 0); }
void addResult(EvaluationResult evaluationResult) { if (!getAlgorithm().equals(evaluationResult.getAlgorithm())) { throw new IllegalArgumentException("Tried to add evaluation result with different algorithm"); } numberOfGood += evaluationResult.getNumberOfGood(); numberOfBad += evaluationResult.getNumberOfBad(); numberOfFoundGood += evaluationResult.getNumberOfFoundGood(); numberOfFoundBad += evaluationResult.getNumberOfFoundBad(); numberOfFoundOthers += evaluationResult.getNumberOfFoundOthers(); errors.addAll(evaluationResult.getErrors()); }
CombinedEvaluationResult extends AbstractEvaluationResult { void addResult(EvaluationResult evaluationResult) { if (!getAlgorithm().equals(evaluationResult.getAlgorithm())) { throw new IllegalArgumentException("Tried to add evaluation result with different algorithm"); } numberOfGood += evaluationResult.getNumberOfGood(); numberOfBad += evaluationResult.getNumberOfBad(); numberOfFoundGood += evaluationResult.getNumberOfFoundGood(); numberOfFoundBad += evaluationResult.getNumberOfFoundBad(); numberOfFoundOthers += evaluationResult.getNumberOfFoundOthers(); errors.addAll(evaluationResult.getErrors()); } }
CombinedEvaluationResult extends AbstractEvaluationResult { void addResult(EvaluationResult evaluationResult) { if (!getAlgorithm().equals(evaluationResult.getAlgorithm())) { throw new IllegalArgumentException("Tried to add evaluation result with different algorithm"); } numberOfGood += evaluationResult.getNumberOfGood(); numberOfBad += evaluationResult.getNumberOfBad(); numberOfFoundGood += evaluationResult.getNumberOfFoundGood(); numberOfFoundBad += evaluationResult.getNumberOfFoundBad(); numberOfFoundOthers += evaluationResult.getNumberOfFoundOthers(); errors.addAll(evaluationResult.getErrors()); } CombinedEvaluationResult(@NotNull Algorithm evaluatingAlgorithm); }
CombinedEvaluationResult extends AbstractEvaluationResult { void addResult(EvaluationResult evaluationResult) { if (!getAlgorithm().equals(evaluationResult.getAlgorithm())) { throw new IllegalArgumentException("Tried to add evaluation result with different algorithm"); } numberOfGood += evaluationResult.getNumberOfGood(); numberOfBad += evaluationResult.getNumberOfBad(); numberOfFoundGood += evaluationResult.getNumberOfFoundGood(); numberOfFoundBad += evaluationResult.getNumberOfFoundBad(); numberOfFoundOthers += evaluationResult.getNumberOfFoundOthers(); errors.addAll(evaluationResult.getErrors()); } CombinedEvaluationResult(@NotNull Algorithm evaluatingAlgorithm); @Override int getNumberOfGood(); @Override int getNumberOfBad(); @Override int getNumberOfFoundGood(); @Override int getNumberOfFoundBad(); @Override int getNumberOfFoundOthers(); @Override List<Double> getErrors(); }
CombinedEvaluationResult extends AbstractEvaluationResult { void addResult(EvaluationResult evaluationResult) { if (!getAlgorithm().equals(evaluationResult.getAlgorithm())) { throw new IllegalArgumentException("Tried to add evaluation result with different algorithm"); } numberOfGood += evaluationResult.getNumberOfGood(); numberOfBad += evaluationResult.getNumberOfBad(); numberOfFoundGood += evaluationResult.getNumberOfFoundGood(); numberOfFoundBad += evaluationResult.getNumberOfFoundBad(); numberOfFoundOthers += evaluationResult.getNumberOfFoundOthers(); errors.addAll(evaluationResult.getErrors()); } CombinedEvaluationResult(@NotNull Algorithm evaluatingAlgorithm); @Override int getNumberOfGood(); @Override int getNumberOfBad(); @Override int getNumberOfFoundGood(); @Override int getNumberOfFoundBad(); @Override int getNumberOfFoundOthers(); @Override List<Double> getErrors(); }
@Test public void testCorrect1() throws IOException { List<String> entries = loadLogs(LOGS_PATH + "correctTest1.txt"); validator.validate(entries); assertEquals(1, result.validLines().size()); assertEquals(0, result.errorLines().size()); }
public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
InputSessionValidator { public void validate(Iterable<String> input) { List<EventLine> errorSession = new ArrayList<>(); List<EventLine> validSession = new ArrayList<>(); for (String line : input) { if (line.trim().isEmpty()) continue; String[] fields = line.split("\t", -1); if (!isFormattedCorrectly(fields)) { errorSession.add(new EventLine(line)); continue; } String payload = fields[7]; if (isCorrectPayload(payload)) { validSession.add(new EventLine(payload)); } else { errorSession.add(new EventLine(payload)); } } result.addErrorSession(errorSession); result.addValidSession(validSession); } InputSessionValidator(org.jetbrains.research.groups.ml_methods.refactoring.validation.SessionValidationResult result); void validate(Iterable<String> input); static void main(String args[]); }
@Test public void testCreateManifest() throws IOException { Resource resource = new ClassPathResource("/repositories/sources/test/ticktock/ticktock-1.0.1"); PackageReader packageReader = new DefaultPackageReader(); Package pkg = packageReader.read(resource.getFile()); assertThat(pkg).isNotNull(); Date date = new Date(666); Map<String, Object> log = new HashMap<>(); log.put("version", "666"); log.put("adate", new Date(666)); log.put("bool", true); log.put("array", "[a, b, c]"); Map<String, String> time = new HashMap<>(); time.put("version", "666"); Map<String, Object> map = new HashMap<>(); map.put("log", log); map.put("time", time); String manifest = ManifestUtils.createManifest(pkg, map); String dateAsStringWithQuotes = "\"" + date.toString() + "\""; assertThat(manifest).contains("\"version\": \"666\"").describedAs("Handle Integer"); assertThat(manifest).contains("\"bool\": \"true\"").describedAs("Handle Boolean"); assertThat(manifest).contains("\"adate\": " + dateAsStringWithQuotes).describedAs("Handle Date"); assertThat(manifest).contains("\"array\":\n - \"a\"\n - \"b\"\n - \"c\"").describedAs("Handle Array"); assertThat(manifest).contains("\"deploymentProperties\": !!null \"null\"").describedAs("Handle Null"); }
@SuppressWarnings("unchecked") public static String createManifest(Package packageToDeploy, Map<String, ?> model) { Map<String, Object> newModel = new HashMap<>(); backslashEscapeMap((Map<String, Object>) model, newModel); String rawManifest = applyManifestTemplate(packageToDeploy, newModel); Yaml yaml = createYaml(); List<Object> yamlList = StreamSupport .stream(yaml.loadAll(rawManifest).spliterator(), false) .collect(Collectors.toList()); return yaml.dumpAll(yamlList.iterator()); }
ManifestUtils { @SuppressWarnings("unchecked") public static String createManifest(Package packageToDeploy, Map<String, ?> model) { Map<String, Object> newModel = new HashMap<>(); backslashEscapeMap((Map<String, Object>) model, newModel); String rawManifest = applyManifestTemplate(packageToDeploy, newModel); Yaml yaml = createYaml(); List<Object> yamlList = StreamSupport .stream(yaml.loadAll(rawManifest).spliterator(), false) .collect(Collectors.toList()); return yaml.dumpAll(yamlList.iterator()); } }
ManifestUtils { @SuppressWarnings("unchecked") public static String createManifest(Package packageToDeploy, Map<String, ?> model) { Map<String, Object> newModel = new HashMap<>(); backslashEscapeMap((Map<String, Object>) model, newModel); String rawManifest = applyManifestTemplate(packageToDeploy, newModel); Yaml yaml = createYaml(); List<Object> yamlList = StreamSupport .stream(yaml.loadAll(rawManifest).spliterator(), false) .collect(Collectors.toList()); return yaml.dumpAll(yamlList.iterator()); } }
ManifestUtils { @SuppressWarnings("unchecked") public static String createManifest(Package packageToDeploy, Map<String, ?> model) { Map<String, Object> newModel = new HashMap<>(); backslashEscapeMap((Map<String, Object>) model, newModel); String rawManifest = applyManifestTemplate(packageToDeploy, newModel); Yaml yaml = createYaml(); List<Object> yamlList = StreamSupport .stream(yaml.loadAll(rawManifest).spliterator(), false) .collect(Collectors.toList()); return yaml.dumpAll(yamlList.iterator()); } static String resolveKind(String manifest); @SuppressWarnings("unchecked") static String createManifest(Package packageToDeploy, Map<String, ?> model); }
ManifestUtils { @SuppressWarnings("unchecked") public static String createManifest(Package packageToDeploy, Map<String, ?> model) { Map<String, Object> newModel = new HashMap<>(); backslashEscapeMap((Map<String, Object>) model, newModel); String rawManifest = applyManifestTemplate(packageToDeploy, newModel); Yaml yaml = createYaml(); List<Object> yamlList = StreamSupport .stream(yaml.loadAll(rawManifest).spliterator(), false) .collect(Collectors.toList()); return yaml.dumpAll(yamlList.iterator()); } static String resolveKind(String manifest); @SuppressWarnings("unchecked") static String createManifest(Package packageToDeploy, Map<String, ?> model); }
@Test public void initialize() throws Exception { assertThat(repositoryRepository.count()).isEqualTo(2); assertThat(repositoryRepository.findByName("test").getUrl()).isEqualTo("classpath:/repositories/binaries/test"); assertThat(packageMetadataRepository.count()).isGreaterThan(5); }
@EventListener @Transactional public void initialize(ApplicationReadyEvent event) { synchronizeRepositories(); synchronizePackageMetadata(); }
RepositoryInitializationService { @EventListener @Transactional public void initialize(ApplicationReadyEvent event) { synchronizeRepositories(); synchronizePackageMetadata(); } }
RepositoryInitializationService { @EventListener @Transactional public void initialize(ApplicationReadyEvent event) { synchronizeRepositories(); synchronizePackageMetadata(); } RepositoryInitializationService(RepositoryRepository repositoryRepository, PackageMetadataRepository packageMetadataRepository, PackageMetadataService packageMetadataService, SkipperServerProperties skipperServerProperties); }
RepositoryInitializationService { @EventListener @Transactional public void initialize(ApplicationReadyEvent event) { synchronizeRepositories(); synchronizePackageMetadata(); } RepositoryInitializationService(RepositoryRepository repositoryRepository, PackageMetadataRepository packageMetadataRepository, PackageMetadataService packageMetadataService, SkipperServerProperties skipperServerProperties); @EventListener @Transactional void initialize(ApplicationReadyEvent event); }
RepositoryInitializationService { @EventListener @Transactional public void initialize(ApplicationReadyEvent event) { synchronizeRepositories(); synchronizePackageMetadata(); } RepositoryInitializationService(RepositoryRepository repositoryRepository, PackageMetadataRepository packageMetadataRepository, PackageMetadataService packageMetadataService, SkipperServerProperties skipperServerProperties); @EventListener @Transactional void initialize(ApplicationReadyEvent event); }
@Test public void testUpdateWithNoConfigReturnsEmptyMap() { MultivaluedMap<String, String> incomingHeaders = mockIncomingHeaders(); MultivaluedMap<String, String> clientOutgoingHeaders = new MultivaluedHashMap<>(); MultivaluedMap<String, String> updatedHeaders = impl.update(incomingHeaders, clientOutgoingHeaders); assertNotNull(updatedHeaders); assertEquals(updatedHeaders.size(), 0); }
@Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); final static String PROPAGATE_PROPERTY; }
@Test public void testUpdateWithConfiguredPropagationHeaders() { System.setProperty(DefaultClientHeadersFactoryImpl.PROPAGATE_PROPERTY, "Authorization,Favorite-Color"); MultivaluedMap<String, String> incomingHeaders = mockIncomingHeaders(); MultivaluedMap<String, String> clientOutgoingHeaders = new MultivaluedHashMap<>(); MultivaluedMap<String, String> updatedHeaders = impl.update(incomingHeaders, clientOutgoingHeaders); assertNotNull(updatedHeaders); assertEquals(updatedHeaders.size(), 2); assertEquals("Basic xyz123", updatedHeaders.getFirst("Authorization")); assertEquals("blue", updatedHeaders.getFirst("Favorite-Color")); }
@Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); final static String PROPAGATE_PROPERTY; }
@Test public void testUpdateWithConfiguredPropagationHeadersAndExistingOutgoingHeaders() { System.setProperty(DefaultClientHeadersFactoryImpl.PROPAGATE_PROPERTY, "Authorization,Favorite-Color"); MultivaluedMap<String, String> incomingHeaders = mockIncomingHeaders(); MultivaluedMap<String, String> clientOutgoingHeaders = mockOutgoingHeaders(); MultivaluedMap<String, String> updatedHeaders = impl.update(incomingHeaders, clientOutgoingHeaders); assertNotNull(updatedHeaders); assertEquals(updatedHeaders.size(), 2); assertEquals("Basic xyz123", updatedHeaders.getFirst("Authorization")); assertEquals("blue", updatedHeaders.getFirst("Favorite-Color")); }
@Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); }
DefaultClientHeadersFactoryImpl implements ClientHeadersFactory { @Override public MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) { if (LOG.isLoggable(Level.FINER)) { LOG.entering(CLASS_NAME, "update", new Object[]{incomingHeaders, clientOutgoingHeaders}); } MultivaluedMap<String, String> propagatedHeaders = new MultivaluedHashMap<>(); Optional<String> propagateHeaderString = getHeadersProperty(); if (propagateHeaderString.isPresent()) { Arrays.stream(propagateHeaderString.get().split(",")) .forEach( header -> { if (incomingHeaders.containsKey(header)) { propagatedHeaders.put(header, incomingHeaders.get(header)); } }); } if (LOG.isLoggable(Level.FINER)) { LOG.exiting(CLASS_NAME, "update", propagatedHeaders); } return propagatedHeaders; } @Override MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders); final static String PROPAGATE_PROPERTY; }
@Test public void all_key_words_can_be_initialzed() { DocumentKeyWord[] results = DocumentKeyWords.getAll(); assertNotNull(results); }
public static DocumentKeyWord[] getAll(){ return ALL_KEYWORDS; }
DocumentKeyWords { public static DocumentKeyWord[] getAll(){ return ALL_KEYWORDS; } }
DocumentKeyWords { public static DocumentKeyWord[] getAll(){ return ALL_KEYWORDS; } }
DocumentKeyWords { public static DocumentKeyWord[] getAll(){ return ALL_KEYWORDS; } static DocumentKeyWord[] getAll(); }
DocumentKeyWords { public static DocumentKeyWord[] getAll(){ return ALL_KEYWORDS; } static DocumentKeyWord[] getAll(); }
@Test public void function_is_functionKeyword() { assertTrue(new ParseToken("function").isFunctionKeyword()); }
public boolean isFunctionKeyword() { return "function".equals(text); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void functions_is_NOT_functionKeyword() { assertFalse(new ParseToken("functions").isFunctionKeyword()); }
public boolean isFunctionKeyword() { return "function".equals(text); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isFunctionKeyword() { return "function".equals(text); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void function_is_NOT_functionName() { assertFalse(new ParseToken("function").isFunction()); }
public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void xyz_is_NOT_functionName() { assertFalse(new ParseToken("xyz").isFunction()); }
public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }