All files / src artifacts_objects.ts

100% Statements 30/30
100% Branches 7/7
100% Functions 2/2
100% Lines 30/30

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 301x 1x 1x 1x 1x 1x 1x 1x 7972x 1x 1x 7972x 7972x 5x 7972x 7967x 7967x 7972x 1x 1x 1x 1x 1x 167x 164x 164x 164x 167x 1x 1x
import {IObject} from "./objects/_iobject";
import * as Objects from "./objects";
import {UnknownObject} from "./objects/_unknown_object";
 
export class ArtifactsObjects {
  private static objectMap: any;
 
  public static newObject(name: string, type: string): IObject {
    if (this.objectMap === undefined) {
      this.buildObjectMap();
    }
 
    if (type === undefined || this.objectMap[type] === undefined) {
      return new UnknownObject(name, type);
    } else {
      return new this.objectMap[type](name);
    }
  }
 
  private static buildObjectMap() {
    this.objectMap = [];
    const list: any = Objects;
    for (const key in Objects) {
      if (typeof list[key] === "function") {
        const obj = new list[key]("DUMMY_NAME");
        this.objectMap[obj.getType()] = list[key];
      }
    }
  }
}