MObjectInfo.java 1.12 KB
package com.model;

import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by yoho on 2016/6/14.
 */
@Data
public class MObjectInfo implements Serializable {
    private int moId = 0;

    private String moName;

    private String moHostIp;

    private int moTypeId;

    //添加一个transient类型的字段,非数据字段
    private String moTypeName;

    private String moTags;

    private String moUrl;

    public Map<String, String> getMoTagsMap() {

        Map<String, String> tagsMap = new HashMap<>();

        if (StringUtils.isNotEmpty(moTags)) {

            String[] tags = moTags.split(",");

            if (null != tags && 0 < tags.length) {

                for (String tagItem : tags) {

                    String[] kv = tagItem.split(":");

                    if (null != kv && 2 == kv.length && StringUtils.isNotBlank(kv[0]) && StringUtils.isNotBlank(kv[1])) {
                        tagsMap.put(kv[0], kv[1]);
                    }
                }
            }
        }
        return tagsMap;
    }

}