make serializable abstract Lazy template

This commit is contained in:
Mark Harrah 2010-10-30 11:55:47 -04:00
parent 2a68806cc5
commit 730b613007
3 changed files with 28 additions and 2 deletions

View File

@ -13,7 +13,7 @@ object SafeLazy
def strict[T <: AnyRef](value: T): xsbti.api.Lazy[T] = apply(value)
private[this] final class Impl[T <: AnyRef](private[this] var eval: () => T) extends xsbti.api.Lazy[T]
private[this] final class Impl[T <: AnyRef](private[this] var eval: () => T) extends xsbti.api.AbstractLazy[T]
{
private[this] lazy val _t =
{

View File

@ -0,0 +1,26 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package xsbti.api;
import java.io.ObjectStreamException;
public abstract class AbstractLazy<T> implements Lazy<T>, java.io.Serializable
{
private Object writeReplace() throws ObjectStreamException
{
return new StrictLazy<T>(get());
}
private static final class StrictLazy<T> implements Lazy<T>, java.io.Serializable
{
private final T value;
StrictLazy(T t)
{
value = t;
}
public T get()
{
return value;
}
}
}

View File

@ -1,5 +1,5 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
* Copyright 2010 Mark Harrah
*/
package xsbti.api;