001package arez.spy; 002 003import arez.Arez; 004import arez.ComputableValue; 005import grim.annotations.OmitSymbol; 006import java.util.List; 007import javax.annotation.Nonnull; 008import javax.annotation.Nullable; 009 010/** 011 * A representation of a ComputableValue instance exposed to spy framework. 012 */ 013public interface ComputableValueInfo 014 extends ElementInfo 015{ 016 /** 017 * Return true if the ComputableValue is "computing". 018 * This implies that the current transaction or one of the parent transactions is calculating the 019 * ComputableValue at the moment. 020 * 021 * @return true if there is a transaction active. 022 */ 023 boolean isComputing(); 024 025 /** 026 * Return the priority of the ComputableValue. 027 * 028 * @return the priority of the ComputableValue. 029 */ 030 @Nonnull 031 Priority getPriority(); 032 033 /** 034 * Return true if the ComputableValue is active. 035 * A ComputableValue is active if there is one or more Observers and the value will be calculated. 036 * 037 * @return true if the ComputableValue is active. 038 */ 039 boolean isActive(); 040 041 /** 042 * Return the list of observers for ComputableValue. 043 * The list is an immutable copy of the observers of the {@link ComputableValue}. 044 * 045 * @return the list of observers for ComputableValue. 046 */ 047 @Nonnull 048 List<ObserverInfo> getObservers(); 049 050 /** 051 * Return the list of dependencies of the ComputableValue. 052 * The list is an immutable copy of the dependencies of the {@link ComputableValue}. 053 * If the {@link ComputableValue} is currently being computed (i.e. {@link #isComputing()} 054 * returns true) then the dependencies are provisional and may be added to as transaction 055 * completes. 056 * 057 * @return the list of dependencies for ComputableValue. 058 */ 059 @Nonnull 060 List<ObservableValueInfo> getDependencies(); 061 062 /** 063 * Return the component for the ComputableValue. 064 * This method should not be invoked if {@link Arez#areNativeComponentsEnabled()} returns false. 065 * 066 * @return the component that contains ComputableValue if any. 067 */ 068 @Nullable 069 ComponentInfo getComponent(); 070 071 /** 072 * Return the value of the ComputableValue. 073 * This method should only be invoked if {@link Arez#arePropertyIntrospectorsEnabled()} returns true. 074 * 075 * @return the value of the ComputableValue. 076 * @throws Throwable if the property accessor throws an exception. 077 */ 078 @OmitSymbol( unless = "arez.enable_property_introspection" ) 079 @Nullable 080 Object getValue() 081 throws Throwable; 082}