001package arez.spy; 002 003import arez.Arez; 004import arez.ComputableValue; 005import java.util.List; 006import javax.annotation.Nonnull; 007import javax.annotation.Nullable; 008 009/** 010 * A representation of a observer instance exposed to spy framework. 011 */ 012public interface ObserverInfo 013 extends ElementInfo 014{ 015 /** 016 * Return true if the Observer is active. 017 * A normal observer is considered active if it is not disposed. An observer where {@link #isComputableValue()} 018 * returns true if the observer is not disposed and either the {@link ComputableValue} is being observed 019 * or has been configured as a <code>keepAlive</code> {@link ComputableValue}. 020 * 021 * @return true if the Observer is active. 022 */ 023 boolean isActive(); 024 025 /** 026 * Return true if the Observer is currently running. 027 * 028 * @return true if the Observer is currently running. 029 */ 030 boolean isRunning(); 031 032 /** 033 * Return true if the Observer is scheduled to run. 034 * 035 * @return true if the Observer is scheduled to run. 036 */ 037 boolean isScheduled(); 038 039 /** 040 * Return true if the Observer is a ComputableValue. 041 * 042 * @return true if the Observer is a ComputableValue. 043 */ 044 boolean isComputableValue(); 045 046 /** 047 * Return true if the Observer will use a read-only transaction. 048 * 049 * @return true if the Observer will use a read-only transaction. 050 */ 051 boolean isReadOnly(); 052 053 /** 054 * Return the priority of the Observer. 055 * 056 * @return the priority of the Observer. 057 */ 058 @Nonnull 059 Priority getPriority(); 060 061 /** 062 * Convert the Observer to a ComputableValue. 063 * This method should only be called if {@link #isComputableValue()} returns true. 064 * 065 * @return the ComputableValue instance. 066 */ 067 ComputableValueInfo asComputableValue(); 068 069 /** 070 * Return the list of dependencies of the Observer. 071 * The list is an immutable copy of the dependencies of the {@link arez.Observer}. 072 * If the {@link arez.Observer} is currently running (i.e. {@link #isRunning()} 073 * returns true) then the dependencies are provisional and may be added to as transaction 074 * completes. 075 * 076 * @return the list of dependencies for the Observer. 077 */ 078 @Nonnull 079 List<ObservableValueInfo> getDependencies(); 080 081 /** 082 * Return the component for the specified Observer. 083 * This method should not be invoked if {@link Arez#areNativeComponentsEnabled()} returns false. 084 * 085 * @return the component that contains Observer if any. 086 */ 087 @Nullable 088 ComponentInfo getComponent(); 089}