Mercurial Hosting > luan
view src/luan/LuanMutable.java @ 1706:93b9fd13a06c
Luan.arg fix
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 Jul 2022 12:30:16 -0600 |
parents | c922446f53aa |
children |
line wrap: on
line source
package luan; import java.util.Map; import java.util.Collection; public interface LuanMutable { public boolean isImmutable(); public void makeImmutable(); public static void makeImmutable(LuanMutable obj) { if( obj==null ) return; obj.makeImmutable(); } public static void makeImmutable(Object[] a) { if( a==null ) return; for( Object obj : a ) { makeImmutable(obj); } } public static void makeImmutable(Map map) { if( map==null ) return; for( Object stupid : map.entrySet() ) { Map.Entry entry = (Map.Entry)stupid; makeImmutable(entry.getKey()); makeImmutable(entry.getValue()); } } public static void makeImmutable(Collection col) { if( col==null ) return; for( Object obj : col ) { makeImmutable(obj); } } public static void makeImmutable(Object obj) { if( obj instanceof LuanMutable ) makeImmutable((LuanMutable)obj); else if( obj instanceof Object[] ) makeImmutable((Object[])obj); else if( obj instanceof Map ) makeImmutable((Map)obj); else if( obj instanceof Collection ) makeImmutable((Collection)obj); } }