001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 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 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 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 */ 016package io.jboot.components.event; 017 018import java.io.Serializable; 019 020public class JbootEvent implements Serializable { 021 022 private static final long serialVersionUID = 1L; 023 024 private final long timestamp; 025 private String action; 026 private Object data; 027 028 public JbootEvent(String action, Object data) { 029 this.action = action; 030 this.data = data; 031 this.timestamp = System.currentTimeMillis(); 032 } 033 034 @SuppressWarnings("unchecked") 035 public <M> M getData() { 036 return (M) data; 037 } 038 039 public String getAction() { 040 return action; 041 } 042 043 044 public long getTimestamp() { 045 return this.timestamp; 046 } 047 048 049 @Override 050 public String toString() { 051 return "JbootEvent [timestamp=" + timestamp + ", action=" + action + ", data=" + data + "]"; 052 } 053 054}