/** * @description Data Transfer Object for {describe the data this DTO represents}. * Used to pass structured data between layers without exposing SObjects. * Serialization-friendly for use with JSON.serialize/deserialize and API responses. * @author Generated by Apex Class Writer Skill * * @example * // Create from constructor * {ClassName} dto = new {ClassName}('value1', 42); * * // Deserialize from JSON * {ClassName} dto = ({ClassName}) JSON.deserialize(jsonString, {ClassName}.class); */ public with sharing class {ClassName} { // ─── Properties ────────────────────────────────────────────────────── /** @description {Describe this property} */ public String name { get; set; } /** @description {Describe this property} */ public Id recordId { get; set; } /** @description {Describe this property} */ public Boolean isActive { get; set; } /** @description {Describe this property} */ public List tags { get; set; } // TODO: Add additional properties as needed // ─── Constructors ──────────────────────────────────────────────────── /** * @description No-arg constructor for deserialization compatibility */ public {ClassName}() { this.tags = new List(); this.isActive = false; } /** * @description Parameterized constructor for convenience * @param name The name value * @param recordId The associated record Id */ public {ClassName}(String name, Id recordId) { this(); this.name = name; this.recordId = recordId; } // ─── Factory Methods ───────────────────────────────────────────────── /** * @description Creates a DTO instance from an SObject record * @param record The source {SObject} record * @return A populated {ClassName} instance */ public static {ClassName} fromSObject(SObject record) { if (record == null) { return new {ClassName}(); } {ClassName} dto = new {ClassName}(); dto.recordId = record.Id; dto.name = (String) record.get('Name'); // TODO: Map additional fields return dto; } /** * @description Creates a list of DTOs from a list of SObject records * @param records The source records * @return List of populated {ClassName} instances */ public static List<{ClassName}> fromSObjects(List records) { List<{ClassName}> dtos = new List<{ClassName}>(); if (records == null) { return dtos; } for (SObject record : records) { dtos.add(fromSObject(record)); } return dtos; } // ─── Utility Methods ───────────────────────────────────────────────── /** * @description Serializes this DTO to a JSON string * @return JSON representation of this DTO */ public String toJson() { return JSON.serialize(this); } /** * @description Deserializes a JSON string into a {ClassName} instance * @param jsonString The JSON string to deserialize * @return A {ClassName} instance */ public static {ClassName} fromJson(String jsonString) { return ({ClassName}) JSON.deserialize(jsonString, {ClassName}.class); } }