All files / src typed-value.ts

100% Statements 21/21
100% Branches 8/8
100% Functions 6/6
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45          1x 25258x 25258x   25258x 25241x 25241x 25241x         25258x 23040x 23040x         25258x 4x 4x         25258x 7x 7x   25258x 5x 5x         25258x 25258x  
/**
 * Parallels Spring TypedValue
 *
 * Wraps evaluation result with type descriptor; core data carrier in the evaluation pipeline.
 */
export class TypedValue {
  private readonly value: unknown;
  private readonly typeDescriptor: unknown;
 
  constructor(value: unknown, typeDescriptor?: unknown) {
    this.value = value;
    this.typeDescriptor = typeDescriptor ?? null;
  }
 
  /**
   * Get raw value
   */
  public getValue(): unknown {
    return this.value;
  }
 
  /**
   * Get type descriptor
   */
  public getTypeDescriptor(): unknown {
    return this.typeDescriptor;
  }
 
  /**
   * Whether is null
   */
  public isNull(): boolean {
    return this.value === null || this.value === undefined;
  }
 
  public toString(): string {
    return String(this.value);
  }
 
  /**
   * TypedValue.NULL singleton, represents null-typed value
   */
  public static readonly NULL = new TypedValue(null);
}