afv-library/skills/apex-class/templates/domain.cls
Mohan Raj Rajamanickam 2320c50264
ci: publish skills as @salesforce/afv-skills npm package @W-21534193@ (#30)
* ci: update package details and add GitHub workflows for skills validation and release

* chore: update Node version, change license, and refactor skills validation script to TypeScript

* chore: remove unused deps

* fix: npm package

* fix: flatten skills to pass validation

* chore: add validation script to package.json and update GitHub workflow to use it

* chore: enhance skills validation and update workflows for npm publishing

* refactor: streamline skills validation process in workflow and script

* refactor: improve documentation and structure of skills validation script

* implement checks based on jeff's best practices doc

* chore: add pull request template for skill submissions

* chore: update pull request template with additional references and improve automated checks section

* chore: update pull request template to clarify naming convention with a warning for gerund form

* chore: update pull request template to reference skill authoring guide and enhance checklist structure

* chore: enhance GitHub workflows for skills validation and release process

* refactor: improve parsing logic for SKILL.md files and enhance error collection in validation

* chore: update validation checks to enforce character limits for skill names and descriptions

* fix: remove unnecessary whitespace in footer string in validate-skills.ts
2026-03-12 13:41:52 -07:00

103 lines
4.2 KiB
OpenEdge ABL

/**
* @description Domain class for {SObject}.
* Encapsulates field-level defaults, derivations, and validations.
* Operates only on in-memory SObject data no SOQL or DML.
* @author Generated by Apex Class Writer Skill
*/
public with sharing class {SObject}Domain {
// Constants
// TODO: Add constants for default values, statuses, etc.
// Field Defaults
/**
* @description Applies default field values to new {SObject} records.
* Call this before insert to ensure consistent defaults.
* @param records List of {SObject} records to apply defaults to
*/
public static void applyDefaults(List<{SObject}> records) {
if (records == null || records.isEmpty()) {
return;
}
for ({SObject} record : records) {
// TODO: Set default field values
// Example:
// if (record.Status__c == null) {
// record.Status__c = DEFAULT_STATUS;
// }
}
}
// Derivations
/**
* @description Derives calculated field values based on other fields.
* Call this before insert and before update.
* @param records List of {SObject} records to derive values for
*/
public static void deriveFields(List<{SObject}> records) {
if (records == null || records.isEmpty()) {
return;
}
for ({SObject} record : records) {
// TODO: Derive calculated field values
// Example:
// record.FullAddress__c = buildFullAddress(record);
}
}
// Validations
/**
* @description Validates {SObject} records and adds errors for any violations.
* Call this before insert and before update.
* @param records List of {SObject} records to validate
*/
public static void validate(List<{SObject}> records) {
if (records == null || records.isEmpty()) {
return;
}
for ({SObject} record : records) {
// TODO: Add validation rules
// Example:
// if (String.isBlank(record.Name)) {
// record.addError('Name is required.');
// }
}
}
// Comparisons
/**
* @description Determines which fields have changed between old and new record versions.
* Useful in before update context.
* @param oldRecord The previous version of the record
* @param newRecord The current version of the record
* @return Set of field API names that have changed
*/
public static Set<String> getChangedFields({SObject} oldRecord, {SObject} newRecord) {
Set<String> changedFields = new Set<String>();
if (oldRecord == null || newRecord == null) {
return changedFields;
}
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.{SObject}.fields.getMap();
for (String fieldName : fieldMap.keySet()) {
if (oldRecord.get(fieldName) != newRecord.get(fieldName)) {
changedFields.add(fieldName);
}
}
return changedFields;
}
// Private Helpers
// TODO: Add private helper methods as needed
}