Created
April 18, 2019 21:08
-
-
Save SalesforceBobLightning/2a42f7ef643baaed6115e9215f435b36 to your computer and use it in GitHub Desktop.
Salesforce Apex hashCode and equals implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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