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

org.nasdanika.resources.EphemeralEntity Maven / Gradle / Ivy

There is a newer version: 2024.9.0
Show newest version
package org.nasdanika.resources;

import org.nasdanika.common.ProgressMonitor;

/**
 * Entity with the state stored in memory.
 * @author Pavel
 *
 * @param 
 */
public abstract class EphemeralEntity implements TypedEntity {

	protected T state;

	@Override
	public T getState(ProgressMonitor monitor) {
		return state;
	}

	@Override
	public void setState(T contents, ProgressMonitor monitor) {
		this.state = contents;
	}

	@Override
	public boolean canRead() {
		return true;
	}

	@Override
	public boolean canWrite() {
		return true;
	}
	
	@Override
	public boolean exists(ProgressMonitor monitor) {
		return state != null;
	}
	
	@Override
	public void delete(ProgressMonitor monitor) {
		setState(null, monitor);	
	}	

	@Override
	public String toString() {
		return getClass().getName()+"("+getPath()+")";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy