com.eywa.impl.app.mongo.entities.items.session.user.ItemSessionDataUser.java Source code

Java tutorial

Introduction

Here is the source code for com.eywa.impl.app.mongo.entities.items.session.user.ItemSessionDataUser.java

Source

/*
 * EYWA.COM (Eywa Commerce)
 * This program is an integrated platform with E-Commerce and Configurator system.
 * Support: Please, contact the Author on http://www.smartfeeling.org.
 * Copyright (C) 2014  Gian Angelo Geminiani
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.eywa.impl.app.mongo.entities.items.session.user;

import com.eywa.impl.app.IAppConstants;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.ly.commons.util.StringUtils;
import org.ly.packages.mongo.impl.util.MongoUtils;

/**
 * Item for Session DATA field.
 * Contains information about user session
 */
public class ItemSessionDataUser extends BasicDBObject {

    private static final String TYPE_USER = "data-user";

    public static final String TYPE = IAppConstants.TYPE; // data type

    public ItemSessionDataUser(final DBObject raw) {
        this.init(raw);
    }

    public ItemSessionDataUser() {
        this.init(null);
    }

    // ------------------------------------------------------------------------
    //                      p r i v a t e
    // ------------------------------------------------------------------------

    private void init(final DBObject raw) {
        this.put(TYPE, TYPE_USER);
        if (null != raw) {

        }
    }

    // ------------------------------------------------------------------------
    //                      S T A T I C
    // ------------------------------------------------------------------------

    public static boolean is(final DBObject item) {
        return is(getType(item));
    }

    public static boolean is(final String type) {
        return StringUtils.hasText(type) && type.equalsIgnoreCase(TYPE_USER);
    }

    public static String getType(final DBObject item) {
        return MongoUtils.getString(item, TYPE);
    }

}