export class Guard {
  private static instance: Guard;

  private constructor() {
    // Constructor is private
  }

  static get Against(): Guard {
    if (!Guard.instance) {
      Guard.instance = new Guard();
    }

    return Guard.instance;
  }

  public NullOrUndefined<T>(value: T | undefined, paramName: string): T {
    if (value === null) throw new TypeError(`${paramName} is null`);

    if (value === undefined) throw new TypeError(`${paramName} is undefined`);

    return value;
  }

  public NullOrEmpty<T>(value: T | undefined, paramName: string): T {
    value = Guard.Against.NullOrUndefined<T>(value, paramName);

    if (!value) throw new TypeError(`${paramName} is empty`);

    return value;
  }  
}