![JAR search and dependency download from the Maven repository](/logo.png)
uk.org.retep.xmpp.muc.beans.BasicMucRoomMember Maven / Gradle / Ivy
/*
* Copyright (c) 1998-2010, Peter T Mount
* All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
*
*
* GNU GENERAL PUBLIC LICENSE - CLASSPATH EXCEPTION
*
*
*
* Linking this library statically or dynamically with other modules
* is making a combined work based on this library. Thus, the terms
* and conditions of the GNU General Public License cover the whole
* combination.
*
*
*
* As a special exception, the copyright holders of this library give
* you permission to link this library with independent modules to
* produce an executable, regardless of the license terms of these
* independent modules, and to copy and distribute the resulting
* executable under terms of your choice, provided that you also meet,
* for each linked independent module, the terms and conditions of the
* license of that module.
*
*
*
* An independent module is a module which is either not derived from or based
* on this library, or a module who's classes extend those within this library
* as part of the implementation of the library.
*
*
*
* If you modify this library, you may extend this exception to your version
* of the library, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
*/
package uk.org.retep.xmpp.muc.beans;
import javax.xml.bind.JAXBElement;
import javax.annotation.concurrent.ThreadSafe;
import uk.org.retep.annotations.ReadLock;
import uk.org.retep.annotations.WriteLock;
import uk.org.retep.annotations.cluster.InstrumentedClass;
import uk.org.retep.util.concurrent.ReadWriteConcurrencySupport;
import uk.org.retep.xmpp.JID;
import uk.org.retep.xmpp.muc.MucRoomMember;
import uk.org.retep.xmpp.util.Affiliation;
import uk.org.retep.xmpp.util.Role;
/**
*
* @author peter
*/
@ThreadSafe
@InstrumentedClass
public class BasicMucRoomMember
extends ReadWriteConcurrencySupport
implements MucRoomMember
{
private String nickname;
private JID jid;
private Affiliation affiliation;
private Role role;
private String persistentNickname;
public BasicMucRoomMember()
{
}
public BasicMucRoomMember( final String nickname, final JID jid )
{
this( nickname, jid, Affiliation.MEMBER, Role.PARTICIPANT );
}
public BasicMucRoomMember( final String nickname,
final JID jid,
final Affiliation affiliation,
final Role role )
{
this.nickname = nickname;
this.jid = jid;
this.affiliation = affiliation;
this.role = role;
}
/**
* {@inheritDoc}
*/
@Override
@ReadLock
public String getNickname()
{
return nickname;
}
/**
* {@inheritDoc}
*/
@Override
@ReadLock
public JID getJID()
{
return jid;
}
/**
* {@inheritDoc}
*/
@Override
@ReadLock
public Affiliation getAffiliation()
{
return affiliation;
}
/**
* {@inheritDoc}
*/
@Override
@ReadLock
public Role getRole()
{
return role;
}
/**
* {@inheritDoc}
*/
@WriteLock
@Override
public void setAffiliation( final Affiliation affiliation )
{
this.affiliation = affiliation == null ? Affiliation.NONE : affiliation;
}
/**
* {@inheritDoc}
*/
@WriteLock
@Override
public void setNickname( final String nickname )
{
this.nickname = nickname;
}
/**
* {@inheritDoc}
*/
@WriteLock
@Override
public void setRole( final Role role )
{
this.role = role == null ? Role.NONE : role;
}
/**
* {@inheritDoc}
*/
@WriteLock
@Override
public void setJID( final JID jid )
{
this.jid = jid;
}
@Override
@ReadLock
public boolean equals( final Object obj )
{
if( obj == null || getClass() != obj.getClass() )
{
return false;
}
final BasicMucRoomMember other = (BasicMucRoomMember) obj;
if( (this.nickname == null) ? (other.nickname != null) : !this.nickname.equals(
other.nickname ) )
{
return false;
}
return true;
}
@Override
@ReadLock
public int hashCode()
{
int hash = 7;
if( nickname != null )
{
hash = 31 * hash + this.nickname.hashCode();
}
return hash;
}
/**
* {@inheritDoc}
*/
@Override
@ReadLock
public String getPersistentNickname()
{
return persistentNickname;
}
/**
* {@inheritDoc}
*/
@Override
@WriteLock
public void setPersistentNickname( final String nickname )
{
persistentNickname = nickname;
}
}