Last active
October 16, 2020 02:06
-
-
Save talesmgodois/62937f13b1a296208a7c64a773997283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EBreeds { | |
private static map = new Map<string, EBreeds>(); | |
public static readonly AKITA = EBreeds.build('AKITA', 'Cão grande branco e peludo'); | |
public static readonly SCOTTISH_TERRIER = EBreeds.build('SCOTTISH_TERRIER', 'Cão pequeno'); | |
private constructor( | |
public readonly code: string, | |
public readonly desc: string | |
) {} | |
public toString(): string { | |
return this.code; | |
} | |
public static getEnumByCode(code: string) { | |
return this.map.get(code); | |
} | |
public equals(breed: EBreeds): boolean { | |
return this.code === breed.code; | |
} | |
public equalsCode(code: string): boolean { | |
return this.code === code; | |
} | |
public static build(code: string, desc: string): EBreeds { | |
const breed = new EBreeds(code, desc); | |
this.map.set(breed.code, breed); | |
return breed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment