com.jivesoftware.sdk.event.AbstractEvent.java Source code

Java tutorial

Introduction

Here is the source code for com.jivesoftware.sdk.event.AbstractEvent.java

Source

/*
 *
 *  * Copyright 2013 Jive Software
 *  *
 *  *    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
 *  *
 *  *       http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    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.jivesoftware.sdk.event;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * Created by rrutan on 2/8/14.
 */
public abstract class AbstractEvent {

    public static final String ERROR = "error";
    public static final String CONTEXT = "context";

    protected Map<String, Object> data;

    protected AbstractEvent() {
        this.data = Maps.newHashMap();
    } // end constructor

    public void setContext(Object object) {
        data.put(CONTEXT, object);
    }

    public Object getContext() {
        if (data.containsKey(CONTEXT)) {
            return data.get(CONTEXT);
        }
        return null;
    } // end getContext

    public void setError(Object object) {
        data.put(ERROR, object);
    }

    public Object getError() {
        if (data.containsKey(ERROR)) {
            return data.get(ERROR);
        }
        return null;
    } // end getError

} // end class