001/** 002 * Copyright 2015 DuraSpace, Inc. 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 */ 016package org.fcrepo.http.commons.webxml.bind; 017 018import javax.xml.bind.annotation.XmlElement; 019import javax.xml.bind.annotation.XmlRootElement; 020 021/** 022 * <p>Listener class.</p> 023 * 024 * @author awoods 025 */ 026@XmlRootElement(namespace = "http://java.sun.com/xml/ns/javaee", 027 name = "listener") 028public class Listener extends Displayable { 029 030 public Listener() { 031 } 032 033 public Listener(final String displayName, final String className) { 034 this.displayName = displayName; 035 this.className = className; 036 } 037 038 @XmlElement(namespace = "http://java.sun.com/xml/ns/javaee", 039 name = "listener-class") 040 String className; 041 042 public String className() { 043 return this.className; 044 } 045 046 @Override 047 public boolean equals(final Object object) { 048 if (object instanceof Listener) { 049 final Listener that = (Listener) object; 050 final boolean className = 051 (this.className == null) ? that.className == null 052 : this.className.equals(that.className); 053 final boolean displayName = 054 (this.displayName == null) ? that.displayName == null 055 : this.displayName.equals(that.displayName); 056 return className && displayName; 057 } 058 return false; 059 } 060 061 @Override 062 public int hashCode() { 063 return className.hashCode() + 2 * displayName.hashCode(); 064 } 065 066}