/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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
 *
 *   http://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 org.apache.pinot.thirdeye.detection.alert;

import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotNull;


/**
 * Container class for email alert recipients
 */
public class DetectionAlertFilterRecipients {
  Set<String> to;
  Set<String> cc;
  Set<String> bcc;

  public DetectionAlertFilterRecipients(Set<String> to, Set<String> cc, Set<String> bcc) {
    this.to = to;
    this.cc = cc;
    this.bcc = bcc;
  }

  public DetectionAlertFilterRecipients(Set<String> to) {
    this.to = to;
  }

  public DetectionAlertFilterRecipients() {
  }

  public Set<String> getTo() {
    return to;
  }

  public DetectionAlertFilterRecipients setTo(Set<String> to) {
    this.to = to;
    return this;
  }

  public Set<String> getCc() {
    return cc;
  }

  public DetectionAlertFilterRecipients setCc(Set<String> cc) {
    this.cc = cc;
    return this;
  }

  public Set<String> getBcc() {
    return bcc;
  }

  public DetectionAlertFilterRecipients setBcc(Set<String> bcc) {
    this.bcc = bcc;
    return this;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    DetectionAlertFilterRecipients that = (DetectionAlertFilterRecipients) o;
    return Objects.equals(to, that.to) && Objects.equals(cc, that.cc) && Objects.equals(bcc, that.bcc);
  }

  @Override
  public int hashCode() {
    return Objects.hash(to, cc, bcc);
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this)
        .add("TO", Arrays.toString((getTo() != null) ? getTo().toArray() : new String[]{}))
        .add("CC", Arrays.toString((getCc() != null) ? getCc().toArray() : new String[]{}))
        .add("BCC", Arrays.toString((getBcc() != null) ? getBcc().toArray() : new String[]{}))
        .toString();
  }
}

@@ -908,82 +908,23 @@
 ort 
-com.google.common.base.Preconditions;%0Aimport com.google.common.collect.Set
+java.util.Array
 s;%0Ai
@@ -931,38 +931,42 @@
 mport java.util.
-Arrays
+Collection
 ;%0Aimport java.ut
@@ -972,19 +972,15 @@
 til.
-Collections
+HashSet
 ;%0Aim
@@ -1029,53 +1029,8 @@
 et;%0A
-import javax.validation.constraints.NotNull;%0A
 %0A%0A/*
@@ -1215,35 +1215,42 @@
 ilterRecipients(
-Set
+Collection
 %3CString%3E to, Set
@@ -1246,19 +1246,26 @@
 ng%3E to, 
-Set
+Collection
 %3CString%3E
@@ -1269,19 +1269,26 @@
 ng%3E cc, 
-Set
+Collection
 %3CString%3E
@@ -1305,26 +1305,41 @@
   this.to = 
+new HashSet%3C%3E(
 to
+)
 ;%0A    this.c
@@ -1338,26 +1338,41 @@
   this.cc = 
+new HashSet%3C%3E(
 cc
+)
 ;%0A    this.b
@@ -1372,27 +1372,42 @@
  this.bcc = 
+new HashSet%3C%3E(
 bcc
+)
 ;%0A  %7D%0A%0A  pub

fix detection alert filter recipients class casting issue (#4158)