export class Epoch {
  id: number;
  name: string;

  static EPOCH = [
    new Epoch(-1, 'Tests'),
    new Epoch(0, 'Pilot'),
    new Epoch(1, 'Epoch 1'),
    new Epoch(2, 'Epoch 2'),
    new Epoch(3, 'Epoch 3')
  ];

  constructor(id: number, name: string) {
    this.id = id;
    this.name = name;
  }

  static getEpochFromId(id: number): Epoch {
    for (const e of Epoch.EPOCH) {
      if (e.id === id) {
        return e;
      }
    }
    return null;
  }

  static getEpochFromName(name: string): Epoch {
    for (const e of Epoch.EPOCH) {
      if (e.name.toLowerCase() === name.toLowerCase()) {
        return e;
      }
    }
    return null;
  }
}