boolean (Object target) { if (this == target) { return true; } if (target instanceof SearchResult targetResult) { if (startPosition.equals(targetResult.startPosition) && endPostion.equals(targetResult.endPostion) && contextPrefix.equals(targetResult.contextPrefix) && foundString.equals(targetResult.foundString) && contextPostfix.equals(targetResult.contextPostfix)) { return true; } } return false; }