// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.graphgeckos.dashboard.datatypes;

import org.springframework.cloud.gcp.data.datastore.core.mapping.Entity;
import org.springframework.cloud.gcp.data.datastore.core.mapping.Field;

/**
 * Contains the log information from a single compilation stage from a given build bot.
 */
@Entity(name = "buildLog")
public class Log {

  // Log type (e.g "stdio")
  @Field(name = "type")
  private String type;

  // Log link (e.g "http://lab.llvm.org:8011/builders/mlir-nvidia/builds/6403/logs/stdio")
  @Field(name = "link")
  private String link;

  /**
   * Used only by Spring GCP.
   */
  public Log() {}

  public Log(String type, String link) {
    this.type = type;
    this.link = link;
  }

  public Log(String[] logComponents) {
    this.type = logComponents[0];
    this.link = logComponents[1];
  }

  public String getType() {
    return type;
  }

  public String getLink() {
    return link;
  }

  public void setType(String type) {
    this.type = type;
  }

  public void setLink(String link) {
    this.link = link;
  }

}

@@ -1630,10 +1630,222 @@
 k;%0A  %7D%0A%0A
+  @Override%0A  public boolean equals(Object o) %7B%0A    if (o == null %7C%7C !(o instanceof Log)) %7B%0A      return false;%0A    %7D%0A%0A    Log other = (Log) o;%0A    return type.equals(other.type) && link.equals(other.link);%0A  %7D%0A%0A
 %7D%0A

Add equals method to Log