package com.bocloud.cmp.model.installation.catalog;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * 物理机内存信息类
 *
 * @author Shaolong_tan
 */
public class MemoryInfo {
    /**
     * 内存基本信息
     */
    private MemoryBasic basic;
    /**
     * 内存条详细信息列表
     */
    private List<Memory> memories;

    /**
     * @return the basic
     */
    public MemoryBasic getBasic() {
        return basic;
    }

    /**
     * @param basic the basic to set
     */
    public void setBasic(Object basic) {
        // the memory basic could be list or map format.
        // If it is list format, we just get the first value.
        if (basic instanceof List) {
            List<MemoryBasic> list = JSONArray.parseArray(JSONObject.toJSONString(basic), MemoryBasic.class);
            this.basic = list.get(0);
        } else {
            this.basic = (MemoryBasic) basic;
        }
    }

    /**
     * @return the memories
     */
    public List<Memory> getMemories() {
        return memories;
    }

    /**
     * @param memories the memories to set
     */
    public void setMemories(List<Memory> memories) {
        this.memories = memories;
    }
}
