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

View File

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