用以加强代码流程可读性的工具类
用于加强代码流程可读性的工具类Java Language:public?class?LayerResult?{??????private?ListBoolean?r
用于加强代码流程可读性的工具类
Java Language:
- public?class?LayerResult?{??
- ????private?List<Boolean>?results?=?new?ArrayList<Boolean>();??
- ????private?int?layer?=?-1;??
- ??????
- ????public?boolean?get(){??
- ????????return?results.get(layer);??
- ????}??
- ??????
- ????public?boolean?set(boolean?result){??
- ????????results.set(layer,?result);??
- ????????return?result;??
- ????}??
- ??????
- ????public?boolean?and(boolean?value){??
- ????????return?set(get()?&&?value);??
- ????}??
- ??????
- ????public?boolean?or(boolean?value){??
- ????????return?set(get()?||?value);??
- ????}??
- ??????
- ????public?void?in(boolean?defaultValue){??
- ????????results.add(defaultValue);??
- ????????layer?++;??
- ????}??
- ??????
- ????public?boolean?out(){??
- ????????layer?--;??
- ????????return?results.remove(layer?+?1);??
- ????}??
- }
?
Javascript Language:- var?LayerResult?=?function(){??
- };??
- LayerResult.prototype?=?{??
- ????results?:?[],??
- ????layer?:?-1,??
- ????get?:?function(){??
- ????????return?results[layer]??
- ????},??
- ????set?:?function(value){??
- ????????results[layer]?=?value;??
- ????????return?value;??
- ????},??
- ????and?:?function(value){??
- ????????return?this.set(this.get()?&&?value);??
- ????},??
- ????or?:?function(value){??
- ????????return?this.set(this.get()?||?value);??
- ????},??
- ????in?:?function(defaultValue){??
- ????????results.push(defaultValue);??
- ????},??
- ????out?:?function(){??
- ????????return?results.pop();??
- ????}??
- }; ?