package com.wx.application.nebula.graph.query;

import java.util.Map;

import cn.hutool.json.JSONObject;
import com.vesoft.nebula.client.graph.data.ValueWrapper;
import com.wx.application.nebula.graph.base.ResultSetUtils;

import lombok.Data;

@SuppressWarnings("rawtypes")
@Data
public class NebulaRelation {
	
	private String srcId;
	
	private String dstId;
	
	private String edgeName;

	private JSONObject properties;

	public void setProperties(JSONObject obj) {
		this.properties = obj;
	}
	
	public void setProperties(Map<String, ValueWrapper> propertiesMap) {
		JSONObject obj = new JSONObject();
		for (Map.Entry<String, ValueWrapper> pro : propertiesMap.entrySet()) {
			obj.set(pro.getKey(), ResultSetUtils.printValueWrapper(pro.getValue()));
		}
		this.properties = obj;
	}
	
	@Override
	public boolean equals(Object obj) {
		NebulaRelation u = (NebulaRelation) obj;
		return this.getSrcId().equals(u.getSrcId())
				&& this.getDstId().equals(u.getDstId());
	}

	@Override
	public int hashCode() {
		String in = this.getSrcId().concat(this.getDstId());
		return in.hashCode();
	}
	
}
