package com.cmobile.unifiedtms.entity.misc; import java.io.Serializable; import java.util.Date; import java.util.concurrent.CountDownLatch; public class TerminalUpdateCacheObj implements Serializable { private String sn; private CountDownLatch countDownLatch; private String status; // started, ongoing, finished private String lastStepName; private Date createdTime; private Date lastStepUpdateTime; public TerminalUpdateCacheObj(String sn) { this.sn = sn; this.countDownLatch = new CountDownLatch(5); this.status = "Started"; this.createdTime = new Date(); } public String getSn() { return sn; } public CountDownLatch getCountDownLatch() { return countDownLatch; } public String getStatus() { return status; } public void continueStep(String stepName) { if(stepName != null && !stepName.equals(this.lastStepName)) { this.lastStepName = stepName; this.lastStepUpdateTime = new Date(); this.countDownLatch.countDown(); if(this.countDownLatch.getCount() == 0) { this.considerDone(); } } } public void considerDone() { this.status = "Finished"; } public String getLastStepName() { return lastStepName; } public Date getCreatedTime() { return createdTime; } public Date getLastStepUpdateTime() { return lastStepUpdateTime; } }