com.shampan.db.collections.fragment.profile.Religion.java Source code

Java tutorial

Introduction

Here is the source code for com.shampan.db.collections.fragment.profile.Religion.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.shampan.db.collections.fragment.profile;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 *
 * @author Sampan-IT
 */
public class Religion {

    private String id;
    private String title;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public String toString() {
        ObjectMapper mapper = new ObjectMapper();
        String json = "";
        try {
            json = mapper.writeValueAsString(this);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return json;
    }

    public static Religion getReligionInfo(String jsonContent) {
        Religion religion = null;
        try {
            ObjectMapper mapper = new ObjectMapper();
            religion = mapper.readValue(jsonContent, Religion.class);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return religion;
    }

}