001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 * $Id$
019 */
020
021package org.nuxeo.runtime.services.event;
022
023/**
024 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
025 */
026public class Event {
027
028    private final String topic;
029
030    private final String id;
031
032    private final Object source;
033
034    private final Object data;
035
036    public Event(String topic, String id, Object source, Object data) {
037        this.topic = topic == null ? "" : topic.intern();
038        this.id = id;
039        this.source = source;
040        this.data = data;
041    }
042
043    public String getTopic() {
044        return topic;
045    }
046
047    public String getId() {
048        return id;
049    }
050
051    public Object getSource() {
052        return source;
053    }
054
055    public Object getData() {
056        return data;
057    }
058
059    @Override
060    public String toString() {
061        return topic + '/' + id + " [" + data + ']';
062    }
063
064}