All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.asg.service.InMemoryObjectWrapper Maven / Gradle / Ivy

package net.anotheria.asg.service;

import net.anotheria.asg.data.DataObject;

/**
 * 

InMemoryObjectWrapper class.

* * @author another * @version $Id: $Id */ public class InMemoryObjectWrapper { /** * The wrapped object. */ private T t ; /** * True if it's a newly created object. */ private boolean created; /** * True if it's an updated object. */ private boolean updated; /** * True if it's a deleted object. */ private boolean deleted; /** * Timestamp of object creation. */ private long createdTimestamp; /** * Timestamp of object update. */ private long updatedTimestamp; /** * Timestmap of object deletion. */ private long deletedTimestamp; /** *

Constructor for InMemoryObjectWrapper.

* * @param aT a T object. */ public InMemoryObjectWrapper(T aT){ this(aT, false); } /** *

Constructor for InMemoryObjectWrapper.

* * @param aT a T object. * @param created a boolean. */ public InMemoryObjectWrapper(T aT, boolean created){ t = aT; this.created = created; createdTimestamp = System.currentTimeMillis(); } /** *

getId.

* * @return a {@link java.lang.String} object. */ public String getId(){ return t.getId(); } /** *

get.

* * @return a T object. */ public T get(){ return t; } /** *

update.

* * @param aT a T object. */ public void update(T aT){ t = aT; updated = true; updatedTimestamp = System.currentTimeMillis(); } /** *

delete.

*/ public void delete(){ t = null; deleted = true; deletedTimestamp = System.currentTimeMillis(); } /** *

toString.

* * @return a {@link java.lang.String} object. */ public String toString(){ return ""+t; } /** *

isCreated.

* * @return a boolean. */ public boolean isCreated() { return created; } /** *

isUpdated.

* * @return a boolean. */ public boolean isUpdated() { return updated; } /** *

isDeleted.

* * @return a boolean. */ public boolean isDeleted() { return deleted; } /** *

Getter for the field createdTimestamp.

* * @return a long. */ public long getCreatedTimestamp() { return createdTimestamp; } /** *

Getter for the field updatedTimestamp.

* * @return a long. */ public long getUpdatedTimestamp() { return updatedTimestamp; } /** *

Getter for the field deletedTimestamp.

* * @return a long. */ public long getDeletedTimestamp() { return deletedTimestamp; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy