package com.persagy.dmp.rwd.iot.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class CurrentDataModel {

	private String objectId;
	private String infoCode;
	private String infoValue;
	private String time;
	private Object data;
	private String error;

	@JsonIgnore
	private String[] infoValueArr;


	public CurrentDataModel() {
	}

	public CurrentDataModel(String objectId, String infoCode) {
		this.objectId = objectId;
		this.infoCode = infoCode;
	}

	public String getMeter() {
		if (this.infoValue == null) {
			return null;
		}
		if (this.infoValueArr == null) {
			this.infoValueArr = this.infoValue.split("-");
		}
		if (this.infoValueArr.length == 0) {
			return null;
		} else {
			return this.infoValueArr[0];
		}
	}

	public String getFunction() {
		if (this.infoValue == null) {
			return null;
		}
		if (this.infoValueArr == null) {
			this.infoValueArr = this.infoValue.split("-");
		}
		if (this.infoValueArr.length < 2) {
			return null;
		} else {
			return this.infoValueArr[1];
		}
	}
}
