deprecate old list funcs

This commit is contained in:
Jonathan Shook
2020-07-07 11:40:31 -05:00
parent 6a22d411a0
commit 9a42aacdbe
2 changed files with 19 additions and 23 deletions

View File

@@ -7,18 +7,19 @@ import java.util.function.LongFunction;
import java.util.function.LongToIntFunction; import java.util.function.LongToIntFunction;
/** /**
* Create a {@code List} from a long input * Create a {@code List} from a long input based on two functions, the first to determine the list size, and the second
* based on two functions, the first to * to populate the list with object values. The input fed to the second function is incremented between elements.
* determine the list size, and the second to populate the list with * <p>
* object values. The input fed to the second function is incremented * To directly create Lists of Strings from the String version of the same mapping functions, simply use {@link
* between elements. * StringList} instead.
* *
* To directly create Lists of Strings from the String version of the same * <p>This function is not recommended, given that the other List functions are more clear about how they construct values.
* mapping functions, simply use {@link StringList} instead. * This function may be removed in the next major release, but it will be retained as deprecated for now.</p>
*/ */
@Categories({Category.collections}) @Categories({Category.collections})
@ThreadSafeMapper @ThreadSafeMapper
@DeprecatedFunction("Use ListSizedStepped") @DeprecatedFunction("Use ListSizedStepped")
@Deprecated
public class List implements LongFunction<java.util.List<Object>> { public class List implements LongFunction<java.util.List<Object>> {
private final LongToIntFunction sizeFunc; private final LongToIntFunction sizeFunc;
@@ -36,7 +37,7 @@ public class List implements LongFunction<java.util.List<Object>> {
int size = sizeFunc.applyAsInt(value); int size = sizeFunc.applyAsInt(value);
java.util.List<Object> list = new ArrayList<>(size); java.util.List<Object> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
list.add(valueFunc.apply(value+i)); list.add(valueFunc.apply(value + i));
} }
return list; return list;
} }

View File

@@ -1,29 +1,24 @@
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_collection; package io.nosqlbench.virtdata.library.basics.shared.from_long.to_collection;
import io.nosqlbench.virtdata.api.annotations.Categories; import io.nosqlbench.virtdata.api.annotations.*;
import io.nosqlbench.virtdata.api.annotations.Category;
import io.nosqlbench.virtdata.api.annotations.Example;
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.LongFunction; import java.util.function.LongFunction;
import java.util.function.LongToIntFunction; import java.util.function.LongToIntFunction;
/** /**
* Create a {@code List<String>} from a long value, * Create a {@code List<String>} from a long value, based on two functions, the first to determine the list size, and
* based on two functions, the first to * the second to populate the list with String values. The input fed to the second function is incremented between
* determine the list size, and the second to populate the list with * elements. Regardless of the object type provided by the second function, {@link java.lang.Object#toString()} is used
* String values. The input fed to the second function is incremented * to get the value to add to the list.
* between elements. Regardless of the object type provided by the * <p>
* second function, {@link java.lang.Object#toString()} is used to get * To create Lists of any type of object simply use {@link List} with an specific value mapping function.
* the value to add to the list.
*
* To create Lists of any type of object simply use {@link List} with
* an specific value mapping function.
*/ */
@Categories({Category.collections}) @Categories({Category.collections})
@ThreadSafeMapper @ThreadSafeMapper
@DeprecatedFunction("Use ListSizedStepped")
@Deprecated
public class StringList implements LongFunction<java.util.List<String>> { public class StringList implements LongFunction<java.util.List<String>> {
private final LongToIntFunction sizeFunc; private final LongToIntFunction sizeFunc;
@@ -41,7 +36,7 @@ public class StringList implements LongFunction<java.util.List<String>> {
int size = sizeFunc.applyAsInt(value); int size = sizeFunc.applyAsInt(value);
java.util.List<String> list = new ArrayList<>(size); java.util.List<String> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
list.add(valueFunc.apply(value+i).toString()); list.add(valueFunc.apply(value + i).toString());
} }
return list; return list;
} }