Lang
BlurObject : objet flou
BlurObject.bind("1234").toLongValue();
PairObject : objet paire
List<String> _key = new ArrayList<String>(); Map<String, String> _value = new HashMap<String, String>(); ... PairObject _pObj = new PairObject(_key, _value); // _pObj.getKey(); // _pObj.getValue();
TreeObject : objet arbre
Object _id = UUIDUtils.UUID(); TreeObject _target = new TreeObject() .put("id", _id) .put("category", new Byte[]{1, 2, 3, 4}) .put("create_time", new Date().getTime(), true) .put("is_locked", true) .put("detail", new TreeObject() .put("real_name", "汉字将被混淆", true) .put("age", 32)); // 这样赋值是List TreeObject _list = new TreeObject(); _list.add("list item 1"); _list.add("list item 2"); // 这样赋值代表Map TreeObject _map = new TreeObject(); _map.put("key1", "keyvalue1"); _map.put("key2", "keyvalue2"); TreeObject idsT = new TreeObject(); idsT.put("ids", _list); idsT.put("maps", _map); // List操作 System.out.println(idsT.get("ids").isList()); System.out.println(idsT.get("ids").getList()); // Map操作 System.out.println(idsT.get("maps").isMap()); System.out.println(idsT.get("maps").getMap()); // _target.put("map", _map); _target.put("list", _list); // System.out.println(_target.get("detail").getMixString("real_name")); // TreeObject对象转换为JSON字符串输出 String _jsonStr = _target.toJson().toJSONString(); System.out.println(_jsonStr); // 通过JSON字符串转换为TreeObject对象-->再转为JSON字符串输出 String _jsonStrTmp = (_target = TreeObject.fromJson(_target.toJson())).toJson().toJSONString(); System.out.println(_jsonStrTmp); System.out.println(_jsonStr.equals(_jsonStrTmp));
Util
À propos du framework YMP couramment utilisé Classes d'outils, nous nous concentrons ici sur les suivantes :
Outil BeanWrapper fourni par ClassUtils, qui est un wrapper d'objet de classe qui donne aux objets des capacités de manipulation d'attributs simples
public static void main(String[] args) throws Exception { // 包裹一个Bean对象 ClassUtils.BeanWrapper<DemoBean> _w = ClassUtils.wrapper(new DemoBean()); // 输出该对象的成员属性名称 for (String _fieldName : _w.getFieldNames()) { System.out.println(_fieldName); } // 为成员属性设置值 _w.setValue("name", "YMP"); // 获取成员属性值 _w.getValue("name"); // 拷贝Bean对象属性到目标对象(不局限相同对象) DemoBean _bean = _w.duplicate(new DemoBean()); // 将对象属性转为Map存储 Map<String, Object> _maps = _w.toMap(); // 通过Map对象构建Bean对象并获取Bean实例 DemoBean _target = ClassUtils.wrapper(DemoBean.class).fromMap(_maps).getTargetObject(); }
Classe d'outil d'exécution RuntimeUtils, obtenez informations relatives à l'exécution ;
Obtenez les variables d'environnement actuelles :
RuntimeUtils.getSystemEnvs(); RuntimeUtils.getSystemEnv("JAVA_HOME");
Déterminez l'environnement d'exécution actuel du système d'exploitation :
RuntimeUtils.isUnixOrLinux(); RuntimeUtils.isWindows();
Obtenez le chemin racine de l'application : si le projet WEB est alors Basé sur.../WEB-INF/, s'il s'agit d'un projet normal, il renverra le chemin où se trouve la classe
RuntimeUtils.getRootPath(); RuntimeUtils.getRootPath(false);
Remplacer les variables d'environnement : support ${root}, ${user .dir} et ${user.home }Remplacement d'espace réservé de variable d'environnement
RuntimeUtils.replaceEnvVariable("${root}/home");