Mercurial Hosting > luan
view src/luan/impl/Pointer.java @ 1561:e1a13e707bf3
start immutable
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 20:24:09 -0700 |
parents | 6a7c6879158d |
children | c922446f53aa |
line wrap: on
line source
package luan.impl; import luan.LuanCloneable; import luan.LuanCloner; import luan.LuanImmutabler; import luan.LuanException; public final class Pointer implements LuanCloneable { private Object o; private boolean immutable = false; public Pointer() {} public Pointer(Object o) { this.o = o; } @Override public Pointer shallowClone() { return new Pointer(); } @Override public void deepenClone(LuanCloneable clone,LuanCloner cloner) { ((Pointer)clone).o = cloner.get(o); } @Override public void makeImmutable(LuanImmutabler immutabler) throws LuanException { immutabler.makeImmutable(o); immutable = true; } public Object get() { return o; } public void set(Object o) throws LuanException { if( immutable ) throw new LuanException("variable is immutable"); this.o = o; } }