1 module hunt.http.codec.http.model.StaticTableHttpField; 2 3 import hunt.http.HttpField; 4 import hunt.http.HttpHeader; 5 import hunt.http.HttpMethod; 6 7 import hunt.Exceptions; 8 9 /** 10 */ 11 class StaticTableHttpField(T) :HttpField { 12 private T value; 13 14 this(HttpHeader header, string name, 15 string valueString, T value) { 16 super(header, name, valueString); 17 static if(is(T == HttpMethod)) 18 { 19 if (value == HttpMethod.Null) 20 throw new IllegalArgumentException(""); 21 } 22 else static if(is(T == class)) 23 { 24 if (value is null) 25 throw new IllegalArgumentException(""); 26 } 27 this.value = value; 28 } 29 30 this(HttpHeader header, string valueString, 31 T value) { 32 this(header, header.asString(), valueString, value); 33 } 34 35 this(string name, string valueString, T value) { 36 super(name, valueString); 37 static if(is(T == HttpMethod)) 38 { 39 if (value == HttpMethod.Null) 40 throw new IllegalArgumentException(""); 41 } 42 else static if(is(T == class)) 43 { 44 if (value is null) 45 throw new IllegalArgumentException(""); 46 } 47 this.value = value; 48 } 49 50 T getStaticValue() { 51 return value; 52 } 53 54 override 55 string toString() { 56 return super.toString() ~ "(evaluated)"; 57 } 58 }