2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.facet
.ui
.libraries
;
19 import org
.jetbrains
.annotations
.NonNls
;
20 import org
.jetbrains
.annotations
.Nullable
;
22 import java
.util
.Arrays
;
27 public class LibraryInfo
{
28 public static final LibraryInfo
[] EMPTY_ARRAY
= new LibraryInfo
[0];
29 private @Nullable final LibraryDownloadInfo myDownloadInfo
;
30 private @NonNls final String myPresentableName
;
31 private @NonNls final String
[] myRequiredClasses
;
33 public LibraryInfo(final @NonNls String presentableName
, final @Nullable @NonNls String version
,
34 final @Nullable @NonNls String downloadingUrl
,
35 final @Nullable String presentableUrl
, final @NonNls String
... requiredClasses
) {
36 myPresentableName
= presentableName
;
37 myRequiredClasses
= requiredClasses
;
38 if (downloadingUrl
!= null) {
39 int dot
= presentableName
.lastIndexOf('.');
40 String prefix
= presentableName
.substring(0, dot
);
41 String suffix
= presentableName
.substring(dot
);
42 myDownloadInfo
= new LibraryDownloadInfo(downloadingUrl
, presentableUrl
, prefix
, suffix
);
45 myDownloadInfo
= null;
49 public LibraryInfo(final @NonNls String presentableName
, final @Nullable LibraryDownloadInfo downloadInfo
, String
... requiredClasses
) {
50 myPresentableName
= presentableName
;
51 myRequiredClasses
= requiredClasses
;
52 myDownloadInfo
= downloadInfo
;
56 public String
getPresentableName() {
57 return myPresentableName
;
61 public String
[] getRequiredClasses() {
62 return myRequiredClasses
;
66 public LibraryDownloadInfo
getDownloadingInfo() {
67 return myDownloadInfo
;
70 public boolean equals(final Object o
) {
71 if (this == o
) return true;
72 if (o
== null || getClass() != o
.getClass()) return false;
74 final LibraryInfo that
= (LibraryInfo
)o
;
76 if (myDownloadInfo
!= null ?
!myDownloadInfo
.equals(that
.myDownloadInfo
) : that
.myDownloadInfo
!= null) return false;
77 if (!myPresentableName
.equals(that
.myPresentableName
)) return false;
78 if (!Arrays
.equals(myRequiredClasses
, that
.myRequiredClasses
)) return false;
83 public int hashCode() {
85 result
= (myDownloadInfo
!= null ? myDownloadInfo
.hashCode() : 0);
86 result
= 31 * result
+ myPresentableName
.hashCode();
87 result
= 31 * result
+ Arrays
.hashCode(myRequiredClasses
);