Options
All
  • Public
  • Public/Protected
  • All
Menu

An interface for equatable objects of the same type. They are checked for equality via a special method equals.

Type parameters

  • T

    Type of the objects to compare.

    class Entity implements Equatable<Entity> {
      private id: number;
      private name: string;
      private mail: string;
    
      constructor(id: number, name: string, mail: string) {
        this.id = id;
        this.name = name;
        this.mail = mail;
      }
    
      equals(rhs: Entity) {
        return rhs !== undefined && this.id === rhs.id;
      }
    }
    const user = DatabaseAPI.getById(1);
    
    // ... some code
    
    // This creates a new user instance
    const sameUser = DatabaseAPI.getById(1);
    
    user === sameUser; // => false
    user.equals(sameUser) // => true

Hierarchy

  • Equatable

Index

Methods

Methods

equals

  • equals(rhs: T): boolean

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc