14
14
15
15
package com .google .devtools .build .lib .analysis .platform ;
16
16
17
- import com .google .common .collect .Iterables ;
17
+ import static com .google .common .base .Predicates .notNull ;
18
+ import static com .google .common .collect .ImmutableList .toImmutableList ;
19
+
20
+ import com .google .common .collect .ImmutableList ;
18
21
import com .google .devtools .build .lib .analysis .ProviderCollection ;
22
+ import java .util .List ;
19
23
import javax .annotation .Nullable ;
20
24
21
25
/** Utility methods to help locate platform-related providers. */
@@ -31,8 +35,11 @@ public static PlatformInfo platform(@Nullable ProviderCollection target) {
31
35
}
32
36
33
37
/** Retrieves and casts {@link PlatformInfo} providers from the given targets. */
34
- public static Iterable <PlatformInfo > platforms (Iterable <? extends ProviderCollection > targets ) {
35
- return Iterables .transform (targets , PlatformProviderUtils ::platform );
38
+ public static ImmutableList <PlatformInfo > platforms (List <? extends ProviderCollection > targets ) {
39
+ return targets .stream ()
40
+ .map (PlatformProviderUtils ::platform )
41
+ .filter (notNull ())
42
+ .collect (toImmutableList ());
36
43
}
37
44
38
45
/** Retrieves and casts the {@link ConstraintSettingInfo} provider from the given target. */
@@ -45,9 +52,12 @@ public static ConstraintSettingInfo constraintSetting(@Nullable ProviderCollecti
45
52
}
46
53
47
54
/** Retrieves and casts {@link ConstraintSettingInfo} providers from the given targets. */
48
- public static Iterable <ConstraintSettingInfo > constraintSettings (
49
- Iterable <? extends ProviderCollection > targets ) {
50
- return Iterables .transform (targets , PlatformProviderUtils ::constraintSetting );
55
+ public static ImmutableList <ConstraintSettingInfo > constraintSettings (
56
+ List <? extends ProviderCollection > targets ) {
57
+ return targets .stream ()
58
+ .map (PlatformProviderUtils ::constraintSetting )
59
+ .filter (notNull ())
60
+ .collect (toImmutableList ());
51
61
}
52
62
53
63
/** Retrieves and casts the {@link ConstraintValueInfo} provider from the given target. */
@@ -65,9 +75,12 @@ public static boolean hasConstraintValue(ProviderCollection target) {
65
75
}
66
76
67
77
/** Retrieves and casts {@link ConstraintValueInfo} providers from the given targets. */
68
- public static Iterable <ConstraintValueInfo > constraintValues (
69
- Iterable <? extends ProviderCollection > targets ) {
70
- return Iterables .transform (targets , PlatformProviderUtils ::constraintValue );
78
+ public static ImmutableList <ConstraintValueInfo > constraintValues (
79
+ List <? extends ProviderCollection > targets ) {
80
+ return targets .stream ()
81
+ .map (PlatformProviderUtils ::constraintValue )
82
+ .filter (notNull ())
83
+ .collect (toImmutableList ());
71
84
}
72
85
73
86
/**
0 commit comments