f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/java/io/protobase/f7/models/BaseObject.java
-rw-r--r--
932
 1package io.protobase.f7.models;
 2
 3import java.util.Arrays;
 4
 5/**
 6 * Base object for all other classes. Gives us the basic equality, comparision, toString, and hash-code capabilities.
 7 */
 8public abstract class BaseObject {
 9  public Object[] significantAttributes() {
10    return new Object[]{};
11  }
12
13  @Override
14  public String toString() {
15    return super.toString();
16  }
17
18  /**
19   * Objects are considered equal if and only if they are of the same class, and their significant attributes are the
20   * same.
21   *
22   * @param other object
23   * @return true if equal.
24   */
25  @Override
26  public boolean equals(Object other) {
27    if (other instanceof BaseObject) {
28      BaseObject basic = ((BaseObject) other);
29      return Arrays.equals(basic.significantAttributes(), significantAttributes());
30    }
31    return super.equals(other);
32  }
33
34  @Override
35  public int hashCode() {
36    return Arrays.hashCode(significantAttributes());
37  }
38}