it.tidalwave.metadata.persistence.event.MetadataPersistenceEvent Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* blueMarine Metadata - open source media workflow
* Copyright (C) 2007-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://bluemarine.tidalwave.it
* SCM: https://kenai.com/hg/bluemarine~metadata-src
*
**********************************************************************************************************************/
package it.tidalwave.metadata.persistence.event;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.EventObject;
/*******************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
******************************************************************************/
public final class MetadataPersistenceEvent extends EventObject
{
private static final long serialVersionUID = 8505342900873411611L;
@Nonnull
private final Class> propertySetClass;
@Nonnull
private final String propertyName;
@CheckForNull
private final Object value;
public MetadataPersistenceEvent (@Nonnull final Object source,
@Nonnull final Class> propertySetClass,
@Nonnull final String propertyName,
@CheckForNull final Object value)
{
super(source);
if (propertySetClass == null)
{
throw new IllegalArgumentException("propertySetClass is mandatory");
}
if (propertyName == null)
{
throw new IllegalArgumentException("propertyName is mandatory");
}
// value may be null
this.propertySetClass = propertySetClass;
this.propertyName = propertyName;
this.value = value;
}
@Nonnull
public String getPropertyName()
{
return propertyName;
}
@Nonnull
public Class> getPropertySetClass()
{
return propertySetClass;
}
@CheckForNull
public Object getValue()
{
return value;
}
@Override
public boolean equals (@CheckForNull final Object object)
{
if (object == null)
{
return false;
}
if (getClass() != object.getClass())
{
return false;
}
final MetadataPersistenceEvent other = (MetadataPersistenceEvent)object;
if (!this.propertySetClass.equals(other.propertySetClass))
{
return false;
}
if (!this.propertyName.equals(other.propertyName))
{
return false;
}
if (this.value != other.value && (this.value == null || !this.value.equals(other.value)))
{
return false;
}
return true;
}
@Override
public int hashCode()
{
int hash = 5;
hash = 83 * hash + this.propertySetClass.hashCode();
hash = 83 * hash + this.propertyName.hashCode();
hash = 83 * hash + (this.value != null ? this.value.hashCode() : 0);
return hash;
}
@Override
@Nonnull
public String toString()
{
return String.format("MetadataPersistenceEvent[%s.%s=%s]", propertySetClass, propertyName, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy