1// generated by diplomat-tool 2import wasm from "./diplomat-wasm.mjs"; 3import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6/** See the [Rust documentation for `YearStyle`](https://docs.rs/icu/latest/icu/datetime/enum.YearStyle.html) for more information. 7*/ 8 9 10export class YearStyle { 11 12 #value = undefined; 13 14 static #values = new Map([ 15 ["Auto", 0], 16 ["Full", 1], 17 ["WithEra", 2] 18 ]); 19 20 static getAllEntries() { 21 return YearStyle.#values.entries(); 22 } 23 24 #internalConstructor(value) { 25 if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { 26 // We pass in two internalConstructor arguments to create *new* 27 // instances of this type, otherwise the enums are treated as singletons. 28 if (arguments[1] === diplomatRuntime.internalConstructor ) { 29 this.#value = arguments[2]; 30 return this; 31 } 32 return YearStyle.#objectValues[arguments[1]]; 33 } 34 35 if (value instanceof YearStyle) { 36 return value; 37 } 38 39 let intVal = YearStyle.#values.get(value); 40 41 // Nullish check, checks for null or undefined 42 if (intVal != null) { 43 return YearStyle.#objectValues[intVal]; 44 } 45 46 throw TypeError(value + " is not a YearStyle and does not correspond to any of its enumerator values."); 47 } 48 49 static fromValue(value) { 50 return new YearStyle(value); 51 } 52 53 get value() { 54 return [...YearStyle.#values.keys()][this.#value]; 55 } 56 57 get ffiValue() { 58 return this.#value; 59 } 60 static #objectValues = [ 61 new YearStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), 62 new YearStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), 63 new YearStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), 64 ]; 65 66 static Auto = YearStyle.#objectValues[0]; 67 static Full = YearStyle.#objectValues[1]; 68 static WithEra = YearStyle.#objectValues[2]; 69 70 constructor(value) { 71 return this.#internalConstructor(...arguments) 72 } 73}