Out a class add method

PHOTO EMBED

Thu Nov 03 2022 11:34:28 GMT+0000 (Coordinated Universal Time)

Saved by @Justus #apex

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('');
}
content_copyCOPY