mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
[cleanup] format and javadoc
This commit is contained in:
parent
22cae6ea2d
commit
17ca25453c
1 changed files with 46 additions and 45 deletions
|
@ -15,6 +15,7 @@
|
|||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.references;
|
||||
|
||||
import org.eclipse.rse.core.references.IRSEBaseReferencedObject;
|
||||
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
|
||||
|
||||
|
@ -24,61 +25,61 @@ import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
|
|||
* The easiest use of this class is to subclass it, but since that is not
|
||||
* always possible, it is not abstract and hence can be leveraged via containment.
|
||||
*/
|
||||
public class SystemReferencingObjectHelper
|
||||
{
|
||||
private IRSEBaseReferencedObject masterObject = null;
|
||||
private IRSEBaseReferencingObject caller = null;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public SystemReferencingObjectHelper(IRSEBaseReferencingObject caller)
|
||||
{
|
||||
super();
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that saves effort of calling setReferencedObject.
|
||||
*/
|
||||
public SystemReferencingObjectHelper(IRSEBaseReferencingObject caller, IRSEBaseReferencedObject obj)
|
||||
{
|
||||
this(caller);
|
||||
setReferencedObject(obj);
|
||||
}
|
||||
|
||||
public class SystemReferencingObjectHelper {
|
||||
|
||||
private IRSEBaseReferencedObject masterObject = null;
|
||||
private IRSEBaseReferencingObject caller = null;
|
||||
|
||||
/**
|
||||
* Set the object to which we reference.
|
||||
* Default constructor.
|
||||
* @param caller the reference that this object is helping.
|
||||
*/
|
||||
public SystemReferencingObjectHelper(IRSEBaseReferencingObject caller) {
|
||||
super();
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that saves effort of calling setReferencedObject.
|
||||
* @param caller the reference that this object is helping.
|
||||
* @param obj the object to which this reference will point.
|
||||
*/
|
||||
public SystemReferencingObjectHelper(IRSEBaseReferencingObject caller, IRSEBaseReferencedObject obj) {
|
||||
this(caller);
|
||||
setReferencedObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object to which this reference will point.
|
||||
* Stores the reference in memory, replacing whatever was there.
|
||||
* Also, calls obj.addReference(caller);
|
||||
* Also calls obj.addReference(caller);
|
||||
* @param obj the object to which this reference will point.
|
||||
*/
|
||||
public void setReferencedObject(IRSEBaseReferencedObject obj)
|
||||
{
|
||||
public void setReferencedObject(IRSEBaseReferencedObject obj) {
|
||||
this.masterObject = obj;
|
||||
if (obj != null)
|
||||
obj.addReference(caller);
|
||||
if (obj != null) obj.addReference(caller);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the object which we reference
|
||||
* Get the object which is referenced. May be null if the reference is not set or has not been resolved.
|
||||
* Attempt to resolve the reference.
|
||||
* @return the referenced object.
|
||||
*/
|
||||
public IRSEBaseReferencedObject getReferencedObject()
|
||||
{
|
||||
return masterObject;
|
||||
public IRSEBaseReferencedObject getReferencedObject() {
|
||||
return masterObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fastpath to getReferencedObject().removeReference(this).
|
||||
* Removes this reference from the referenced object and clears this reference.
|
||||
* Also, nulls out our memory reference.
|
||||
* @return new reference count of master object
|
||||
*/
|
||||
public int removeReference()
|
||||
{
|
||||
int newCount = 0;
|
||||
IRSEBaseReferencedObject masterObject = getReferencedObject();
|
||||
if (masterObject != null)
|
||||
newCount = masterObject.removeReference(caller);
|
||||
masterObject = null;
|
||||
return newCount;
|
||||
}
|
||||
public int removeReference() {
|
||||
int newCount = 0;
|
||||
IRSEBaseReferencedObject masterObject = getReferencedObject();
|
||||
if (masterObject != null) newCount = masterObject.removeReference(caller);
|
||||
masterObject = null;
|
||||
return newCount;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue