Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.presidentio.testdatagenerator.provider;
public class SelectProvider implements ValueProvider<Object> {
    private String[] items;
    private String delimiter = ",";
    private Random random = new Random();
    public void init(Map<StringStringprops) {
        Map<StringStringpropsCopy = new HashMap<>(props);
        if (propsCopy.containsKey(.)) {
             = propsCopy.remove(.);
        String items = propsCopy.remove(.);
        if (items == null) {
            throw new IllegalArgumentException("Items does not specified or null");
        this. = items.split();
        if (this..length <= 0) {
            throw new IllegalArgumentException("Items are empty");
        if (!propsCopy.isEmpty()) {
            throw new IllegalArgumentException("Redundant props for RandomProvider: " + propsCopy);
    public Object nextValue(Context contextField field) {
        int index = .nextInt(.);
        return TypeConverter.convert([index], field.getType());
New to GrepCode? Check out our FAQ X