1
1
package org .hydev .mcpm .client .export ;
2
2
3
- import org .hydev .mcpm .client .installer .InstallResult ;
4
-
5
- import java .util .EnumSet ;
6
3
import java .util .Map ;
7
4
5
+
8
6
/**
9
- * Result for importing plugins
10
- *
11
- * @param installResults Result of each install
7
+ * Class storing results of the
12
8
*/
13
- public record ImportResult (Map <String , InstallResult > installResults ) {
9
+ public class ImportResult {
10
+ private State state ;
11
+ private Map <String , Boolean > installResults ;
12
+
13
+ /**
14
+ * Result for importing plugins
15
+ *
16
+ * @param installResults Result of each install
17
+ */
18
+ public ImportResult (Map <String , Boolean > installResults ) {
19
+ this .installResults = installResults ;
20
+ }
21
+
22
+
14
23
/**
15
24
* State of a single import
16
25
*/
@@ -27,16 +36,26 @@ public enum State {
27
36
*/
28
37
public State getState ()
29
38
{
39
+ if (state != null )
40
+ return state ;
30
41
boolean success = true ;
31
42
boolean fail = false ;
32
43
33
- /*
34
- EnumSet<InstallResult> = new RegularEnumSet <>();
35
- for (InstallResult x : installResults .values()) {
36
- success &= x. type();
37
- fail |= x.type( );
44
+ /* Code for when import returns ImportResult instead of boolean
45
+ Set<Type> good = new HashSet <>();
46
+ for (Type type : Type .values()) {
47
+ if ( type.name().contains("SUCCESS")) // definitely legit
48
+ good.add(type );
38
49
}
39
- */
40
- return State .SUCCESS ;
50
+ */
51
+
52
+ for (var x : installResults .values ()) {
53
+ success &= x ;
54
+ fail |= x ;
55
+ if (!success && fail ) // not a full success nor full failure
56
+ return state = State .PARTIAL_SUCCESS ;
57
+ }
58
+
59
+ return state = success ? State .SUCCESS : State .FAILURE ;
41
60
}
42
61
}
0 commit comments