Java tutorial
/* * Copyright 2015 berni. * * 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 org.kisoonlineapp.security.event; import java.io.Serializable; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; /** * * @author berni */ public class UserEvent implements Serializable { public enum UserEventType { undefined, beforeLogin, afterSuccessfulLogin, afterFailedLogin, beforeLogout, afterSuccesfulLogout, afterFailedLogout } private UserEventType userEventType; protected UserEvent() { this(UserEventType.undefined); } public UserEvent(UserEventType userEventType) { this.userEventType = userEventType; } public UserEventType getUserEventType() { return userEventType; } @Override public String toString() { ToStringBuilder tsb = new ToStringBuilder(this); tsb.append("userEventType", userEventType); String toString = tsb.build(); return toString; } @Override public int hashCode() { HashCodeBuilder hcb = new HashCodeBuilder(); hcb.append(this.userEventType); int hashCode = hcb.build(); return hashCode; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof UserEvent)) { return false; } final UserEvent other = (UserEvent) obj; EqualsBuilder eb = new EqualsBuilder(); eb.append(this.userEventType, other.userEventType); Boolean equals = eb.build(); return equals; } }