condition.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import type { ActionManager } from "./actionManager";
  2. /**
  3. * A Condition applied to an Action
  4. */
  5. export declare class Condition {
  6. /**
  7. * Internal only - manager for action
  8. * @internal
  9. */
  10. _actionManager: ActionManager;
  11. /**
  12. * @internal
  13. */
  14. _evaluationId: number;
  15. /**
  16. * @internal
  17. */
  18. _currentResult: boolean;
  19. /**
  20. * Creates a new Condition
  21. * @param actionManager the manager of the action the condition is applied to
  22. */
  23. constructor(actionManager: ActionManager);
  24. /**
  25. * Check if the current condition is valid
  26. * @returns a boolean
  27. */
  28. isValid(): boolean;
  29. /**
  30. * @internal
  31. */
  32. _getProperty(propertyPath: string): string;
  33. /**
  34. * @internal
  35. */
  36. _getEffectiveTarget(target: any, propertyPath: string): any;
  37. /**
  38. * Serialize placeholder for child classes
  39. * @returns the serialized object
  40. */
  41. serialize(): any;
  42. /**
  43. * @internal
  44. */
  45. protected _serialize(serializedCondition: any): any;
  46. }
  47. /**
  48. * Defines specific conditional operators as extensions of Condition
  49. */
  50. export declare class ValueCondition extends Condition {
  51. /** path to specify the property of the target the conditional operator uses */
  52. propertyPath: string;
  53. /** the value compared by the conditional operator against the current value of the property */
  54. value: any;
  55. /** the conditional operator, default ValueCondition.IsEqual */
  56. operator: number;
  57. private static _IsEqual;
  58. private static _IsDifferent;
  59. private static _IsGreater;
  60. private static _IsLesser;
  61. /**
  62. * returns the number for IsEqual
  63. */
  64. static get IsEqual(): number;
  65. /**
  66. * Returns the number for IsDifferent
  67. */
  68. static get IsDifferent(): number;
  69. /**
  70. * Returns the number for IsGreater
  71. */
  72. static get IsGreater(): number;
  73. /**
  74. * Returns the number for IsLesser
  75. */
  76. static get IsLesser(): number;
  77. /**
  78. * Internal only The action manager for the condition
  79. * @internal
  80. */
  81. _actionManager: ActionManager;
  82. private _target;
  83. private _effectiveTarget;
  84. private _property;
  85. /**
  86. * Creates a new ValueCondition
  87. * @param actionManager manager for the action the condition applies to
  88. * @param target for the action
  89. * @param propertyPath path to specify the property of the target the conditional operator uses
  90. * @param value the value compared by the conditional operator against the current value of the property
  91. * @param operator the conditional operator, default ValueCondition.IsEqual
  92. */
  93. constructor(actionManager: ActionManager, target: any,
  94. /** path to specify the property of the target the conditional operator uses */
  95. propertyPath: string,
  96. /** the value compared by the conditional operator against the current value of the property */
  97. value: any,
  98. /** the conditional operator, default ValueCondition.IsEqual */
  99. operator?: number);
  100. /**
  101. * Compares the given value with the property value for the specified conditional operator
  102. * @returns the result of the comparison
  103. */
  104. isValid(): boolean;
  105. /**
  106. * Serialize the ValueCondition into a JSON compatible object
  107. * @returns serialization object
  108. */
  109. serialize(): any;
  110. /**
  111. * Gets the name of the conditional operator for the ValueCondition
  112. * @param operator the conditional operator
  113. * @returns the name
  114. */
  115. static GetOperatorName(operator: number): string;
  116. }
  117. /**
  118. * Defines a predicate condition as an extension of Condition
  119. */
  120. export declare class PredicateCondition extends Condition {
  121. /** defines the predicate function used to validate the condition */
  122. predicate: () => boolean;
  123. /**
  124. * Internal only - manager for action
  125. * @internal
  126. */
  127. _actionManager: ActionManager;
  128. /**
  129. * Creates a new PredicateCondition
  130. * @param actionManager manager for the action the condition applies to
  131. * @param predicate defines the predicate function used to validate the condition
  132. */
  133. constructor(actionManager: ActionManager,
  134. /** defines the predicate function used to validate the condition */
  135. predicate: () => boolean);
  136. /**
  137. * @returns the validity of the predicate condition
  138. */
  139. isValid(): boolean;
  140. }
  141. /**
  142. * Defines a state condition as an extension of Condition
  143. */
  144. export declare class StateCondition extends Condition {
  145. /** Value to compare with target state */
  146. value: string;
  147. /**
  148. * Internal only - manager for action
  149. * @internal
  150. */
  151. _actionManager: ActionManager;
  152. private _target;
  153. /**
  154. * Creates a new StateCondition
  155. * @param actionManager manager for the action the condition applies to
  156. * @param target of the condition
  157. * @param value to compare with target state
  158. */
  159. constructor(actionManager: ActionManager, target: any,
  160. /** Value to compare with target state */
  161. value: string);
  162. /**
  163. * Gets a boolean indicating if the current condition is met
  164. * @returns the validity of the state
  165. */
  166. isValid(): boolean;
  167. /**
  168. * Serialize the StateCondition into a JSON compatible object
  169. * @returns serialization object
  170. */
  171. serialize(): any;
  172. }