/*
 * Copyright 2000-2009 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 com.intellij.ide.util.importProject;

import com.intellij.openapi.util.NlsSafe;

import java.io.File;
import java.util.Collection;
import java.util.Collections;

/**
 * @author Eugene Zhuravlev
 */
public final class LibraryDescriptor implements Dependency {

  private @NlsSafe String myName;
  private final Collection<File> myJars;

  public LibraryDescriptor(String name, Collection<File> jars) {
    myName = name;
    myJars = jars;
  }

  public @NlsSafe String getName() {
    return myName != null? myName : "";
  }

  public void setName(final String name) {
    myName = name;
  }

  public Collection<File> getJars() {
    return Collections.unmodifiableCollection(myJars);
  }
  
  public void addJars(Collection<? extends File> jars) {
    myJars.addAll(jars);
  }
  
  public void removeJars(Collection<? extends File> jars) {
    myJars.removeAll(jars);
  }

  @Override
  public String toString() {
    return "Lib[" + myName + "]";
  }

  @Override
  public int getWeight() {
    return myJars.size() > 1 ? 30 : 40;
  }
}
