/*
 * Copyright 2000-2011 JetBrains s.r.o.
 *
 * 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
 *
 * 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 jetbrains.buildServer.nuget.server.trigger.impl;

import jetbrains.buildServer.nuget.server.exec.SourcePackageInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

/**
 * @author Eugene Petrenko (eugene.petrenko@gmail.com)
 *         Date: 30.09.11 15:40
 */
public class CheckResult {
  private final Collection<SourcePackageInfo> myInfos;
  private final String myError;

  private CheckResult(Collection<SourcePackageInfo> infos, String error) {
    myInfos = infos;
    myError = error;
  }

  public static CheckResult failed(@Nullable final String error) {
    return new CheckResult(null, error == null ? "Error" : error);
  }

  public static CheckResult succeeded(@NotNull final Collection<SourcePackageInfo> infos) {
    return new CheckResult(infos, null);
  }

  @NotNull
  public Collection<SourcePackageInfo> getInfos() {
    if (myError != null) throw new RuntimeException(myError);
    return myInfos;
  }

  @Nullable
  public String getError() {
    return myError;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    CheckResult that = (CheckResult) o;

    if (myError != null ? !myError.equals(that.myError) : that.myError != null) return false;
    if (myInfos != null ? !myInfos.equals(that.myInfos) : that.myInfos != null) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = myInfos != null ? myInfos.hashCode() : 0;
    result = 31 * result + (myError != null ? myError.hashCode() : 0);
    return result;
  }
}

@@ -823,24 +823,53 @@
 ullable;%0D%0A%0D%0A
+import java.util.ArrayList;%0D%0A
 import java.
@@ -1496,21 +1496,55 @@
 kResult(
+new ArrayList%3CSourcePackageInfo%3E(
 infos
+)
 , null);

copy found SourcePackageInfo collection in CheckResult