From f0eaa44cab615fe666ffa682e4654fc6f538a734 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 13 Jan 2010 18:28:28 +0000 Subject: [PATCH] clone() modernization. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@872 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/jme/util/ShaderConfig.java | 24 +++++++++---------- src/java/com/threerings/media/tile/Tile.java | 4 ++-- .../threerings/miso/data/MisoSceneModel.java | 6 ++--- .../com/threerings/miso/data/ObjectInfo.java | 6 ++--- .../miso/data/SimpleMisoSceneModel.java | 2 +- .../miso/data/SparseMisoSceneModel.java | 6 ++--- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/java/com/threerings/jme/util/ShaderConfig.java b/src/java/com/threerings/jme/util/ShaderConfig.java index 05857bcd..d0763a4d 100644 --- a/src/java/com/threerings/jme/util/ShaderConfig.java +++ b/src/java/com/threerings/jme/util/ShaderConfig.java @@ -88,11 +88,10 @@ public abstract class ShaderConfig } @Override // documentation inherited - public Object clone () + public ShaderConfig clone () { - ShaderConfig other = null; try { - other = (ShaderConfig)super.clone(); + ShaderConfig other = (ShaderConfig)super.clone(); other._state = DisplaySystem.getDisplaySystem().getRenderer().createGLSLShaderObjectsState(); other._state.setProgramID(_state.getProgramID()); @@ -112,10 +111,11 @@ public abstract class ShaderConfig other._textures[ii] = (TextureConfig)_textures[ii].clone(); } } + return other; + } catch (CloneNotSupportedException e) { - // will not happen + throw new AssertionError(e); } - return other; } /** @@ -309,13 +309,12 @@ public abstract class ShaderConfig } @Override // documentation inherited - public Object clone () + public LightConfig clone () { try { - return super.clone(); + return (LightConfig) super.clone(); } catch (CloneNotSupportedException e) { - // will not happen - return null; + throw new AssertionError(e); } } @@ -341,13 +340,12 @@ public abstract class ShaderConfig } @Override // documentation inherited - public Object clone () + public TextureConfig clone () { try { - return super.clone(); + return (TextureConfig) super.clone(); } catch (CloneNotSupportedException e) { - // will not happen - return null; + throw new AssertionError(e); } } diff --git a/src/java/com/threerings/media/tile/Tile.java b/src/java/com/threerings/media/tile/Tile.java index 6056275c..4cc8ebe2 100644 --- a/src/java/com/threerings/media/tile/Tile.java +++ b/src/java/com/threerings/media/tile/Tile.java @@ -135,12 +135,12 @@ public class Tile // implements Cloneable // /** // * Creates a shallow copy of this tile object. // */ -// public Object clone () +// public Tile clone () // { // try { // return (Tile)super.clone(); // } catch (CloneNotSupportedException cnse) { -// throw new RuntimeException(cnse); +// throw new AssertionError(cnse); // } // } diff --git a/src/java/com/threerings/miso/data/MisoSceneModel.java b/src/java/com/threerings/miso/data/MisoSceneModel.java index c1a42769..ec0ac0c3 100644 --- a/src/java/com/threerings/miso/data/MisoSceneModel.java +++ b/src/java/com/threerings/miso/data/MisoSceneModel.java @@ -112,12 +112,12 @@ public abstract class MisoSceneModel extends SimpleStreamableObject public abstract boolean removeObject (ObjectInfo info); @Override - public Object clone () + public MisoSceneModel clone () { try { - return super.clone(); + return (MisoSceneModel) super.clone(); } catch (CloneNotSupportedException cnse) { - throw new RuntimeException(cnse); + throw new AssertionError(cnse); } } } diff --git a/src/java/com/threerings/miso/data/ObjectInfo.java b/src/java/com/threerings/miso/data/ObjectInfo.java index 4a3389bf..a68caff9 100644 --- a/src/java/com/threerings/miso/data/ObjectInfo.java +++ b/src/java/com/threerings/miso/data/ObjectInfo.java @@ -166,12 +166,12 @@ public class ObjectInfo extends SimpleStreamableObject } @Override - public Object clone () + public ObjectInfo clone () { try { - return super.clone(); + return (ObjectInfo) super.clone(); } catch (CloneNotSupportedException cnse) { - throw new RuntimeException(cnse); + throw new AssertionError(cnse); } } diff --git a/src/java/com/threerings/miso/data/SimpleMisoSceneModel.java b/src/java/com/threerings/miso/data/SimpleMisoSceneModel.java index 82b87c97..5834701c 100644 --- a/src/java/com/threerings/miso/data/SimpleMisoSceneModel.java +++ b/src/java/com/threerings/miso/data/SimpleMisoSceneModel.java @@ -189,7 +189,7 @@ public class SimpleMisoSceneModel extends MisoSceneModel } @Override - public Object clone () + public SimpleMisoSceneModel clone () { SimpleMisoSceneModel model = (SimpleMisoSceneModel)super.clone(); model.baseTileIds = baseTileIds.clone(); diff --git a/src/java/com/threerings/miso/data/SparseMisoSceneModel.java b/src/java/com/threerings/miso/data/SparseMisoSceneModel.java index 026ac85d..f9d3d293 100644 --- a/src/java/com/threerings/miso/data/SparseMisoSceneModel.java +++ b/src/java/com/threerings/miso/data/SparseMisoSceneModel.java @@ -226,7 +226,7 @@ public class SparseMisoSceneModel extends MisoSceneModel } @Override - public Object clone () { + public Section clone () { try { Section section = (Section)super.clone(); section.baseTileIds = baseTileIds.clone(); @@ -236,7 +236,7 @@ public class SparseMisoSceneModel extends MisoSceneModel section.objectInfo = objectInfo.clone(); return section; } catch (CloneNotSupportedException cnse) { - throw new RuntimeException(cnse); + throw new AssertionError(cnse); } } @@ -453,7 +453,7 @@ public class SparseMisoSceneModel extends MisoSceneModel } @Override - public Object clone () + public SparseMisoSceneModel clone () { SparseMisoSceneModel model = (SparseMisoSceneModel)super.clone(); model._sections = new StreamableHashIntMap
();