⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex7_31.txt

📁 j2ee core design patterns
💻 TXT
字号:
Example 7.31 Implementing the Updatable Transfer Object Strategy

...
public class ProjectEntity implements EntityBean {
	private EntityContext context;
	...

	// attributes and other methods as in 
	// Example 7.4 on page 331 
	...

	// method to set entity values with a transfer object
	public void setProjectData(ProjectTO updatedProj) {
		mergeProjectData(updatedProj);
	}

	// method to merge values from the transfer object 
	// into the entity bean attributes
	private void mergeProjectData(ProjectTO updatedProj) {
		// version control check may be necessary here 
		// before merging changes in order to 
		// prevent losing updates by other clients
		projectId = updatedProj.projectId;
		projectName = updatedProj.projectName;
		managerId = updatedProj.managerId;
		startDate = updatedProj.startDate;
		endDate = updatedProj.endDate;
		customerId = updatedProj.customerId;
		projectDescription = updatedProj.projectDescription;
		projectStatus = updatedProj.projectStatus;
		started = updatedProj.started;
		completed = updatedProj.completed;
		accepted = updatedProj.accepted;
		closed = updatedProj.closed;
	}
	...
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -