📄 station.java
字号:
package com.utstar.fcs.domain.workinstruction;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
public class Station {
private Long id;
private String name;
private StationType stationType = new StationType();
private Map<String, StationVersion> versions = new HashMap<String, StationVersion>();
private WorkInstruction workInstruction=new WorkInstruction();
public Station() {
}
public Station(String name,StationType stationType) {
this.name = name;
this.stationType = stationType;
}
public StationVersion getLatestVersion() {
if(versions.isEmpty())
return null;
SortedSet<String> ss = new TreeSet<String>();
Iterator<String> it = versions.keySet().iterator();
while (it.hasNext())
ss.add(it.next());
return versions.get(ss.last());
}
//deal with lazy load
public void iteratorVersions(){
Iterator<StationVersion> it = versions.values().iterator();
while(it.hasNext())
{
it.next().getVersion();
}
}
public static Station getSample(StationType stationType, String name) {
Station station = new Station();
station.setStationType(stationType);
station.setName(name);
StationVersion sv1 = station.addVersion(StationVersion.getSample(station));
StationVersion sv2 = station.addVersion(StationVersion.getSample(station));
StationVersion sv3 = sv2.cloneEntity();
station.addVersion(sv3);
return station;
}
public StationVersion addVersion(StationVersion stationVersion) {
VersionNumber vn = null;
if (getLatestVersion() == null)
vn = new VersionNumber();
else
vn = new VersionNumber(getLatestVersion().getVersion());
stationVersion.setVersion(vn.getNext());
stationVersion.setStation(this);
versions.put(stationVersion.getVersion(), stationVersion);
return stationVersion;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public StationType getStationType() {
return stationType;
}
public void setStationType(StationType stationType) {
this.stationType = stationType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, StationVersion> getVersions() {
return versions;
}
public void setVersions(Map<String, StationVersion> versions) {
this.versions = versions;
}
public WorkInstruction getWorkInstruction() {
return workInstruction;
}
public void setWorkInstruction(WorkInstruction workInstruction) {
this.workInstruction = workInstruction;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -