Interface JmeCloneable

All Superinterfaces:
Cloneable
All Known Subinterfaces:
AnimTrack<T>, ClonableTrack, EmitterShape, ParticleInfluencer
All Known Implementing Classes:
AbstractBox, AbstractControl, AbstractPhysicsControl, AbstractPhysicsDebugControl, AbstractShadowFilter, AbstractShadowRenderer, AbstractTween, Action, Animation, AnimClip, AnimComposer, AnimControl, AnimLayer, Armature, ArmatureDebugger, ArmatureInterJointsWire, ArmatureNode, Arrow, AssetLinkNode, AudioNode, AudioTrack, BaseAction, BatchNode, BatchNode.Batch, BetterCharacterControl, BillboardControl, BitmapText, BlendableAction, BlendAction, Bone, BoneLink, BoneTrack, BoundingSphereDebug, Box, BulletCharacterDebugControl, BulletGhostObjectDebugControl, BulletJointDebugControl, BulletRigidBodyDebugControl, BulletVehicleDebugControl, CameraControl, CameraNode, CenterQuad, CenterQuad, CharacterControl, ChaseCamera, ClipAction, CompactArray, CompactFloatArray, CompactQuaternionArray, CompactVector3Array, Curve, Cylinder, DacConfiguration, DacLinks, DefaultParticleInfluencer, DirectionalLightShadowFilter, DirectionalLightShadowRenderer, Dome, DynamicAnimControl, EffectTrack, EffectTrack.KillParticleControl, EmitterBoxShape, EmitterMeshConvexHullShape, EmitterMeshFaceShape, EmitterMeshVertexShape, EmitterPointShape, EmitterSphereShape, EmptyParticleInfluencer, Geometry, GeometryGroupNode, GhostControl, Grid, InstancedGeometry, InstancedNode, IntMap, IntMap.Entry, Joint, JointShape, KinematicRagdollControl, LightControl, LightList, LightNode, Line, LodControl, Mesh, MorphControl, MorphTrack, MotionEvent, MotionTrack, MultiTerrainLodControl, NewtonianParticleInfluencer, Node, NormalRecalcControl, ParticleEmitter, ParticleEmitter.ParticleEmitterControl, ParticleMesh, ParticlePointMesh, ParticleTriMesh, PhysicsLink, Picture, PointLightShadowFilter, PointLightShadowRenderer, PQTorus, Quad, RadialParticleInfluencer, RectangleMesh, RigidBodyControl, SimpleBatchNode, Skeleton, SkeletonControl, SkeletonDebugger, SkeletonInterBoneWire, SkeletonPoints, SkeletonWire, SkinningControl, Spatial, SpatialTrack, Sphere, SpotLightShadowFilter, SpotLightShadowRenderer, StatsView, StripBox, Surface, TerrainGrid, TerrainGridLodControl, TerrainLodControl, TerrainPatch, TerrainQuad, TorsoLink, Torus, TrackInfo, TransformTrack, UpdateControl, VehicleControl, VRDirectionalLightShadowRenderer, WaterFilter, WireBox, WireFrustum, WireSphere

public interface JmeCloneable extends Cloneable
Indicates an object that wishes to more actively participate in the two-part deep copying process provided by the Cloner. Objects implementing this interface can access the already cloned object graph to resolve their local dependencies in a way that will be equivalent to the original object graph. In other words, if two objects in the graph share the same target reference then the cloned version will share the cloned reference.

For example, if an object wishes to deep clone one of its fields then it will call cloner.clone(object) instead of object.clone(). The cloner will keep track of any clones already created for 'object' and return that instead of a new clone.

Cloning of a JmeCloneable object is done in two parts. First, the standard Java clone() method is called to create a shallow clone of the object. Second, the cloner will call the cloneFields() method to let the object deep clone any of its fields that should be cloned.

This two part process is necessary to facilitate circular references. When an object calls cloner.clone() during its cloneFields() method, it may get only a shallow copy that will be filled in later.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cloneFields(Cloner cloner, Object original)
    Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.
    Performs a regular shallow clone of the object.
  • Method Details

    • jmeClone

      Object jmeClone()
      Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)

      This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.

      Returns:
      a new instance
    • cloneFields

      void cloneFields(Cloner cloner, Object original)
      Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.

      Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.

      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.