case 0: return Collections.emptyList(); case 1: return Collections.singletonList(merged.get(0)); default: return Containers.unmodifiableList(CollectionsExt.toArray(merged, Identifier.class));
case 0: return Collections.emptyList(); case 1: return Collections.singletonList(merged.get(0)); default: return Containers.unmodifiableList(CollectionsExt.toArray(merged, Identifier.class));
/** * Tests {@link CollectionsExt#toArray(Collection, Class)}. * * @since 0.6 */ @Test public void testToArray() { final String[] expected = new String[] {"One", "Two", "Three"}; final String[] actual = CollectionsExt.toArray(Arrays.asList(expected), String.class); assertArrayEquals(expected, actual); } }
/** * Creates a new descriptor with the same properties than the {@code provided} one, but completed with * information not found in GML. Those extra information are given by the {@code complete} descriptor. * * <p>It is the caller's responsibility to construct the {@code merged} properties as a merge of the properties * of the two given descriptors. This can be done with the help of {@link #mergeArrays(String, Class, Collection, * Map, Identifier)} among others.</p> */ private static <T> ParameterDescriptor<T> create(final Map<String,?> merged, final ParameterDescriptor<?> provided, final ParameterDescriptor<T> complete) { final Class<T> valueClass = complete.getValueClass(); return new DefaultParameterDescriptor<>(merged, provided.getMinimumOccurs(), provided.getMaximumOccurs(), // Values below this point are not provided in GML documents, // so they must be inferred from the pre-defined descriptor. valueClass, Parameters.getValueDomain(complete), CollectionsExt.toArray(complete.getValidValues(), valueClass), complete.getDefaultValue()); }
/** * Creates a new descriptor with the same properties than the {@code provided} one, but completed with * information not found in GML. Those extra information are given by the {@code complete} descriptor. * * <p>It is the caller's responsibility to construct the {@code merged} properties as a merge of the properties * of the two given descriptors. This can be done with the help of {@link #mergeArrays(String, Class, Collection, * Map, Identifier)} among others.</p> */ private static <T> ParameterDescriptor<T> create(final Map<String,?> merged, final ParameterDescriptor<?> provided, final ParameterDescriptor<T> complete) { final Class<T> valueClass = complete.getValueClass(); return new DefaultParameterDescriptor<>(merged, provided.getMinimumOccurs(), provided.getMaximumOccurs(), // Values below this point are not provided in GML documents, // so they must be inferred from the pre-defined descriptor. valueClass, Parameters.getValueDomain(complete), CollectionsExt.toArray(complete.getValidValues(), valueClass), complete.getDefaultValue()); }