1 /* 2 * hunt-console eases the creation of beautiful and testable command line interfaces. 3 * 4 * Copyright (C) 2018-2019, HuntLabs 5 * 6 * Website: https://www.huntlabs.net 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.console.descriptor.DescriptorOptions; 13 14 import hunt.collection.HashMap; 15 import hunt.collection.Map; 16 import hunt.util.Common; 17 18 class DescriptorOptions : Cloneable 19 { 20 private Map!(string, string) _options; 21 22 23 public this() 24 { 25 _options = new HashMap!(string, string)(); 26 } 27 28 private this(DescriptorOptions options) 29 { 30 _options = new HashMap!(string, string)(); 31 this._options.putAll(options._options); 32 } 33 34 public DescriptorOptions set(string name, string value) 35 { 36 return set(name, value, true); 37 } 38 39 public DescriptorOptions set(string name, string value, bool overwrite) 40 { 41 if (overwrite || !_options.containsKey(name)) { 42 _options.put(name, value); 43 } 44 45 return this; 46 } 47 48 public string get(string name) 49 { 50 return _options.get(name); 51 } 52 53 public bool has(string name) 54 { 55 return _options.containsKey(name); 56 } 57 58 public Object clone() 59 { 60 return cast(Object)_options; 61 } 62 }