com.sumit.test.factory.StringValueFactory.java Source code

Java tutorial

Introduction

Here is the source code for com.sumit.test.factory.StringValueFactory.java

Source

/*
 *  Copyright 2015 Jasper Infotech (P) Limited . All Rights Reserved.
 *  JASPER INFOTECH PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *  
 *  @version     1.0, 13-Sep-2015
 *  @author sumit
 */
package com.sumit.test.factory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import net.thumbtack.test.model.VendorDoc;

public class StringValueFactory implements IValueFactory<String> {

    private static ObjectMapper om = new ObjectMapper();

    @Override
    public String create(long index) {
        VendorDoc vendorDoc = new VendorDoc(index);
        try {
            return om.writeValueAsString(vendorDoc);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}