1
- package io .sloeber .core .managers ;
1
+ package io .sloeber .core .Gson ;
2
2
3
3
import java .io .File ;
4
4
import java .util .ArrayList ;
21
21
* @author jan
22
22
*
23
23
*/
24
- public class LibraryIndex {
24
+ public class LibraryIndexJson {
25
25
private String jsonFileName ;
26
- private List <Library > libraries ;
26
+ private List <LibraryJson > libraries ;
27
27
28
28
// category name to library name
29
29
private Map <String , Set <String >> categories = new HashMap <>();
30
30
31
31
// library name to latest version of library
32
- private Map <String , Library > latestLibs = new HashMap <>();
32
+ private Map <String , LibraryJson > latestLibs = new HashMap <>();
33
33
34
34
public void resolve () {
35
- for (Library library : this .libraries ) {
35
+ for (LibraryJson library : this .libraries ) {
36
36
String name = library .getName ();
37
37
38
38
String category = library .getCategory ();
@@ -47,7 +47,7 @@ public void resolve() {
47
47
}
48
48
categoryLibs .add (name );
49
49
50
- Library current = this .latestLibs .get (name );
50
+ LibraryJson current = this .latestLibs .get (name );
51
51
if (current != null ) {
52
52
if (Version .compare (library .getVersion (), current .getVersion ()) > 0 ) {
53
53
this .latestLibs .put (name , library );
@@ -58,21 +58,21 @@ public void resolve() {
58
58
}
59
59
}
60
60
61
- public Library getLatestLibrary (String name ) {
61
+ public LibraryJson getLatestLibrary (String name ) {
62
62
return this .latestLibs .get (name );
63
63
}
64
64
65
- public Library getLibrary (String libName , String version ) {
66
- for (Library library : this .libraries ) {
65
+ public LibraryJson getLibrary (String libName , String version ) {
66
+ for (LibraryJson library : this .libraries ) {
67
67
if (library .getName ().equals (libName ) && (library .getVersion ().equals (version ))) {
68
68
return library ;
69
69
}
70
70
}
71
71
return null ;
72
72
}
73
73
74
- public Library getInstalledLibrary (String libName ) {
75
- for (Library library : this .libraries ) {
74
+ public LibraryJson getInstalledLibrary (String libName ) {
75
+ for (LibraryJson library : this .libraries ) {
76
76
if (library .getName ().equals (libName ) && library .isInstalled ()) {
77
77
return library ;
78
78
}
@@ -84,20 +84,20 @@ public Set<String> getCategories() {
84
84
return this .categories .keySet ();
85
85
}
86
86
87
- public Collection <Library > getLatestLibraries (String category ) {
87
+ public Collection <LibraryJson > getLatestLibraries (String category ) {
88
88
Set <String > categoryLibs = this .categories .get (category );
89
89
if (categoryLibs == null ) {
90
90
return new ArrayList <>(0 );
91
91
}
92
92
93
- List <Library > libs = new ArrayList <>(categoryLibs .size ());
93
+ List <LibraryJson > libs = new ArrayList <>(categoryLibs .size ());
94
94
for (String name : categoryLibs ) {
95
95
libs .add (this .latestLibs .get (name ));
96
96
}
97
97
return libs ;
98
98
}
99
99
100
- public Map <String , Library > getLatestLibraries () {
100
+ public Map <String , LibraryJson > getLatestLibraries () {
101
101
return this .latestLibs ;
102
102
}
103
103
@@ -110,22 +110,22 @@ public Map<String, Library> getLatestLibraries() {
110
110
*/
111
111
public Map <String , LibraryDescriptor > getLatestInstallableLibraries () {
112
112
Map <String , LibraryDescriptor > ret = new HashMap <>();
113
- for (Entry <String , Library > curLibrary : this .latestLibs .entrySet ()) {
113
+ for (Entry <String , LibraryJson > curLibrary : this .latestLibs .entrySet ()) {
114
114
if (!curLibrary .getValue ().isAVersionInstalled ()) {
115
115
ret .put (curLibrary .getKey (),new LibraryDescriptor ( curLibrary .getValue ()));
116
116
}
117
117
}
118
118
return ret ;
119
119
}
120
120
121
- public Collection <Library > getLibraries (String category ) {
121
+ public Collection <LibraryJson > getLibraries (String category ) {
122
122
Set <String > categoryLibs = this .categories .get (category );
123
123
if (categoryLibs == null ) {
124
124
return new ArrayList <>(0 );
125
125
}
126
126
127
- List <Library > libs = new ArrayList <>(categoryLibs .size ());
128
- for (Library curLibrary : this .libraries ) {
127
+ List <LibraryJson > libs = new ArrayList <>(categoryLibs .size ());
128
+ for (LibraryJson curLibrary : this .libraries ) {
129
129
if (categoryLibs .contains (curLibrary .getName ())) {
130
130
libs .add (curLibrary );
131
131
}
@@ -159,7 +159,7 @@ public Map<String, LibraryDescriptor> getLatestInstallableLibraries(Set<String>
159
159
if (libNames .isEmpty ()) {
160
160
return ret ;
161
161
}
162
- for (Entry <String , Library > curLibrary : this .latestLibs .entrySet ()) {
162
+ for (Entry <String , LibraryJson > curLibrary : this .latestLibs .entrySet ()) {
163
163
if (libNames .contains (curLibrary .getKey ())) {
164
164
if (!curLibrary .getValue ().isAVersionInstalled ()) {
165
165
ret .put (curLibrary .getKey (), new LibraryDescriptor (curLibrary .getValue ()));
0 commit comments