Source:
<code>public ContentletRelationships getAllRelationships(Contentlet contentlet)throws DotDataException { ContentletRelationships cRelationships = new ContentletRelationships(contentlet); ContentType contentType = contentlet.getContentType(); List<ContentletRelationshipRecords> matches = cRelationships.getRelationshipsRecords(); <START> List<Relationship> relationships = FactoryLocator.getRelationshipFactory().byContentType(contentType); <END> for (Relationship relationship : relationships) { ContentletRelationshipRecords records = null; List<Contentlet> contentletList = null; if (FactoryLocator.getRelationshipFactory().sameParentAndChild(relationship)) { records = cRelationships.new ContentletRelationshipRecords(relationship, false); contentletList = new ArrayList<Contentlet> (); try { contentletList.addAll(getRelatedContent(contentlet, relationship, false, APILocator.getUserAPI().getSystemUser(), true)); } catch (DotSecurityException e) { Logger.error(this,"Unable to get system user",e); } records.setRecords(contentletList); matches.add(records); records = cRelationships.new ContentletRelationshipRecords(relationship, true); contentletList = new ArrayList<> (); try { contentletList.addAll(getRelatedContent(contentlet, relationship, true, APILocator.getUserAPI().getSystemUser(), true)); } catch (DotSecurityException e) { Logger.error(this,"Unable to get system user",e); } records.setRecords(contentletList); matches.add(records); } else { records = cRelationships.new ContentletRelationshipRecords(relationship, FactoryLocator.getRelationshipFactory() .isParent(relationship, contentType)); try { contentletList = getRelatedContent(contentlet, relationship, APILocator.getUserAPI().getSystemUser(), true); } catch (DotSecurityException e) { Logger.error(this, "Unable to get system user", e); } records.setRecords(contentletList); matches.add(records); } } return cRelationships; }</code><technical_language>I set final</technical_language>

Target:
public ContentletRelationships getAllRelationships(Contentlet contentlet)throws DotDataException { final ContentletRelationships cRelationships = new ContentletRelationships(contentlet); final ContentType contentType = contentlet.getContentType(); final List<ContentletRelationshipRecords> matches = cRelationships.getRelationshipsRecords(); final List<Relationship> relationships = FactoryLocator.getRelationshipFactory() .byContentType(contentType); for (Relationship relationship : relationships) { ContentletRelationshipRecords records; List<Contentlet> contentletList = null; if (FactoryLocator.getRelationshipFactory().sameParentAndChild(relationship)) { records = cRelationships.new ContentletRelationshipRecords(relationship, false); contentletList = new ArrayList<Contentlet> (); try { contentletList.addAll(getRelatedContent(contentlet, relationship, false, APILocator.getUserAPI().getSystemUser(), true)); } catch (DotSecurityException e) { Logger.error(this,"Unable to get system user",e); } records.setRecords(contentletList); matches.add(records); records = cRelationships.new ContentletRelationshipRecords(relationship, true); contentletList = new ArrayList<> (); try { contentletList.addAll(getRelatedContent(contentlet, relationship, true, APILocator.getUserAPI().getSystemUser(), true)); } catch (DotSecurityException e) { Logger.error(this,"Unable to get system user",e); } records.setRecords(contentletList); matches.add(records); } else { records = cRelationships.new ContentletRelationshipRecords(relationship, FactoryLocator.getRelationshipFactory() .isParent(relationship, contentType)); try { contentletList = getRelatedContent(contentlet, relationship, APILocator.getUserAPI().getSystemUser(), true); } catch (DotSecurityException e) { Logger.error(this, "Unable to get system user", e); } records.setRecords(contentletList); matches.add(records); } } return cRelationships; }