Skip to content

Instantly share code, notes, and snippets.

@SalesforceBobLightning
Created April 18, 2019 21:08
Show Gist options
  • Save SalesforceBobLightning/2a42f7ef643baaed6115e9215f435b36 to your computer and use it in GitHub Desktop.
Save SalesforceBobLightning/2a42f7ef643baaed6115e9215f435b36 to your computer and use it in GitHub Desktop.
Salesforce Apex hashCode and equals implementation
public class Request {
@InvocableVariable(label = 'Template Name' required=true)
public String templateName;
@InvocableVariable(label = 'To Number' required=true)
public String toNumber;
@InvocableVariable(label = 'whoId' required=true)
public Id whoId;
@InvocableVariable(label = 'WhatId' required=true)
public Id whatId;
public Integer hashCode()
{
return 17 + (31 * templateName.hashCode()) + (31 * toNumber.hashCode()) + (31 * String.valueOf(whoId).hashCode()) + (31 * String.valueOf(whatId).hashCode());
}
public Boolean equals(Object obj)
{
Request other = (Request) obj;
return other != null && this.templateName == other.templateName && this.toNumber == other.toNumber && this.whoId == other.whoId && this.whatId == other.whatId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment