Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 154743

Summary: Unnecessary complication in AbstractEditPart#setModel() and AbstractEditPart#setParent()
Product: [Tools] GEF Reporter: Pratik Shah <ppshah>
Component: GEF-Legacy GEF (MVC)Assignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: nyssen
Version: 3.2   
Target Milestone: 3.7.1 (Indigo) M5   
Hardware: All   
OS: All   
Whiteboard:

Description Pratik Shah CLA 2006-08-22 14:59:36 EDT
The setModel() method in AbstractEditPart looks like this:

public void setModel(Object model) {
	if (getModel() == model)
		return;
	this.model = model;
}

The getModel() check is not necessary.  It's a minor issue (and there are workarounds), but could create a problem in some cases (for instance, when the model could be an EMF proxy and needs to be replaced with the resolved EObject when getModel() is invoked).
Comment 1 Alexander Nyßen CLA 2011-01-16 17:26:11 EST
As there is no side-effect (e.g. resulting notification) in this method, the check is really not necessary. The same holds for setParent(). 

Thus changed implementation of setModel to:

public void setModel(Object model) {
	this.model = model;
}

Accordingly, changed implementation of setParent() to

public void setParent(EditPart parent) {
		this.parent = parent;
}

Committed changes to cvs HEAD (3.7).