Preview:
writeAddMethod('controllingFields','ControllingField', 'String');
writeAddMethod('actionOverrides','ActionOverride', 'ActionOverride');
writeAddMethod('childRelationships','ChildRelationship', 'ChildRelationship');
writeAddMethod('fields','Field', 'Field');
writeAddMethod('namedLayoutInfos','NamedLayoutInfo', 'NamedLayoutInfo');
writeAddMethod('recordTypeInfos','RecordTypeInfo', 'RecordTypeInfo');
writeAddMethod('supportedScopes','ScopeInfo', 'ScopeInfo');

/**
 * Method to quickly write an add method to for a class
 */
void writeAddMethod(String listVariableName, String className, String dataType){
	System.debug('/**');
	System.debug(' * Method to add a '+dataType+' Object to the ' + listVariableName + ' variable');
	System.debug(' */');
	System.debug('global void add' + className + '(' + dataType + ' ' + className.uncapitalize()+'){');
	System.debug('	if(this.' + listVariableName + ' == null){');
	System.debug('		this.' + listVariableName + ' = new ' + dataType+'[]{};');
	System.debug('	}');
	System.debug('	this.' + listVariableName + '.add(' + className.uncapitalize() + ');');
	System.debug('}');
	System.debug('');
	System.debug('');
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter