|
16 | 16 | import groovy.lang.Closure; |
17 | 17 | import groovy.lang.GroovyObjectSupport; |
18 | 18 | import groovy.lang.MissingPropertyException; |
19 | | -import org.gradle.api.provider.ProviderConvertible; |
20 | | -import org.jetbrains.annotations.Contract; |
21 | | -import org.jetbrains.annotations.Nullable; |
22 | | - |
23 | 19 | import java.util.Map; |
24 | 20 |
|
25 | 21 | import javax.inject.Inject; |
@@ -89,43 +85,15 @@ public void mappings(String channel, String version) { |
89 | 85 | getMappingVersion().set(version); |
90 | 86 | } |
91 | 87 |
|
92 | | - public void mappings(Object channel, Object version) { |
93 | | - try { |
94 | | - getMappingChannel().set(valueOf(channel, String.class)); |
95 | | - getMappingVersion().set(valueOf(version, String.class)); |
96 | | - } catch (IllegalArgumentException e) { |
97 | | - throw new IllegalArgumentException("Tried to set mappings using non-Strings", e); |
98 | | - } |
99 | | - } |
100 | | - |
101 | | - public void mappings(Map<String, ?> mappings) { |
102 | | - Object channel = mappings.get("channel"); |
103 | | - Object version = mappings.get("version"); |
| 88 | + public void mappings(Map<String, ? extends CharSequence> mappings) { |
| 89 | + CharSequence channel = mappings.get("channel"); |
| 90 | + CharSequence version = mappings.get("version"); |
104 | 91 |
|
105 | 92 | if (channel == null || version == null) { |
106 | 93 | throw new IllegalArgumentException("Must specify both mappings channel and version"); |
107 | 94 | } |
108 | 95 |
|
109 | | - mappings(channel, version); |
110 | | - } |
111 | | - |
112 | | - @Contract("!null, _ -> !null") |
113 | | - private static <T> @Nullable T valueOf(@Nullable Object object, Class<T> castTo) { |
114 | | - if (object instanceof ProviderConvertible<?>) |
115 | | - object = ((ProviderConvertible<?>) object).asProvider().get(); |
116 | | - else if (object instanceof Provider<?>) |
117 | | - object = ((Provider<?>) object).get(); |
118 | | - |
119 | | - if (object == null) |
120 | | - return null; |
121 | | - |
122 | | - try { |
123 | | - return castTo.cast(object); |
124 | | - } catch (ClassCastException e) { |
125 | | - throw new IllegalArgumentException(String.format( |
126 | | - "Expected class %s but got class %s for value: %s", castTo.getName(), object.getClass().getName(), object) |
127 | | - ); |
128 | | - } |
| 96 | + mappings(channel.toString(), version.toString()); |
129 | 97 | } |
130 | 98 |
|
131 | 99 | public ConfigurableFileCollection getAccessTransformers() { |
|
0 commit comments