net.java.truevfs.kernel.impl.CheckedCloseable.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truevfs-kernel-impl Show documentation
Show all versions of truevfs-kernel-impl Show documentation
Implements the API for accessing the federated virtual file system space.
This reference implementation can get overridden by providing another
file system manager factory implementation with a higher priority on
the class path.
/*
* Copyright (C) 2005-2012 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truevfs.kernel.impl
import net.java.truecommons.io._
import edu.umd.cs.findbugs.annotations._
import java.io._
import javax.annotation.concurrent._
/**
* @author Christian Schlichtherle
*/
@NotThreadSafe
private trait CheckedCloseable extends Closeable {
private[this] var closed: Boolean = _
/**
* Closes this object.
* Subsequent calls to this method will just forward the call to the
* abstract super class.
*/
@DischargesObligation
final abstract override def close() { closed = true; super.close() }
final def isOpen = !closed;
protected def check() { if (!isOpen) throw new ClosedStreamException }
protected final def checked[V](operation: => V) = { check(); operation }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy