📄 updateevent.java
字号:
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas |
| |
| 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. A copy of the license has been included with |
| these distribution in the COPYING file, if not go to www.fsf.org |
| |
| As a special exception, you are granted the permissions to link this |
| program with every library, which license fulfills the Open Source |
| Definition as published by the Open Source Initiative (OSI). |
*--------------------------------------------------------------------------*/
package org.rapla.storage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.rapla.entities.storage.RefEntity;
public class UpdateEvent implements java.io.Serializable,Cloneable
{
private static final long serialVersionUID = 1L;
HashMap removeSet = new HashMap();
HashMap storeSet = new HashMap();
ArrayList removeObjects = new ArrayList();
ArrayList storeObjects = new ArrayList();
Object userId;
long repositoryVersion;
public UpdateEvent() {
}
public void setUserId( Object userId) {
this.userId = userId;
}
public Object getUserId() {
return userId;
}
private void addRemove(RefEntity entity) {
removeObjects.add(entity);
removeSet.put( entity.getId(),entity);
}
private void addStore(RefEntity entity) {
storeObjects.add(entity);
storeSet.put( entity.getId(), entity);
}
public List getRemoveObjects() {
return removeObjects;
}
public List getStoreObjects() {
return storeObjects;
}
/** use this method if you want to avoid adding the same Entity twice.*/
public void putStore(RefEntity entity) {
if (storeSet.get(entity.getId()) == null)
addStore(entity);
}
/** use this method if you want to avoid adding the same Entity twice.*/
public void putRemove(RefEntity entity) {
if (removeSet.get(entity.getId()) == null)
addRemove(entity);
}
/** find an entity in the update-event that matches the passed original. Returns null
* if no such entity is found. */
public RefEntity findEntity(RefEntity original) {
RefEntity entity = (RefEntity) storeSet.get( original.getId());
if ( entity != null)
return entity;
entity = (RefEntity) removeSet.get( original.getId());
if ( entity != null)
return entity;
return null;
}
public Object clone() {
UpdateEvent clone = new UpdateEvent( );
clone.userId = userId;
clone.removeObjects = (ArrayList) removeObjects.clone();
clone.storeObjects = (ArrayList) storeObjects.clone();
clone.removeSet = (HashMap) removeSet.clone();
clone.storeSet = (HashMap) storeSet.clone();
return clone;
}
public long getRepositoryVersion()
{
return repositoryVersion;
}
public void setRepositoryVersion( long repositoryVersion )
{
this.repositoryVersion = repositoryVersion;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -