Class CopyProperties

java.lang.Object
com.j3d.engine.scene.copy.CopyProperties

public class CopyProperties extends Object
The properties used when a copy operation is applied. (When calling GObject.copy(CopyProperties)

A callee, gets an existing list of GObject to copy, and creates the CopyOperation. Then after the callee needs to call GObject.copy(CopyProperties) on every single object on the list in order of points, lines and tris. (or else tis thing finna break.)

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • softDependencies

      private boolean softDependencies
    • copies

      private final HashSet<Copy> copies
    • objects

      private final ArrayList<GObject> objects
  • Constructor Details

  • Method Details

    • setSoftDependencies

      protected void setSoftDependencies(boolean severeConnections)
      Sets the dependency handling mode for this copy operation. If soft dependencies are enabled, missing dependencies will be created via a supplier. If disabled, an InvalidCopyException will be thrown for missing dependencies.
      Parameters:
      severeConnections - If true, enables soft dependency handling. If false, disables it.
    • allowsSoftDependencies

      public boolean allowsSoftDependencies()
      Checks if soft dependency handling is currently enabled.
      Returns:
      true if soft dependencies are allowed, false otherwise.
    • add

      public void add(UUID original, GObject copy)
      Adds a new original-copy pair to the collection of managed copies.
      Parameters:
      original - The UUID of the original GObject.
      copy - The GObject instance that is a copy of the original.
    • get

      public GObject get(UUID original) throws InvalidCopyException
      Retrieves the copied GObject associated with a given original UUID.
      Parameters:
      original - The UUID of the original GObject to look for.
      Returns:
      The copied GObject if found, or null if no copy for the given original UUID exists.
      Throws:
      InvalidCopyException
    • exists

      public boolean exists(UUID original)
      Checks if a copy for a given original UUID already exists in the collection.
      Parameters:
      original - The UUID of the original GObject to check for.
      Returns:
      true if a copy exists for the original UUID, false otherwise.
    • getCopies

      public HashSet<Copy> getCopies()
      Returns the internal HashSet of Copy objects managed by this CopyProperties instance. Each Copy object represents an original-copy pair.
      Returns:
      A HashSet containing all the Copy objects.
    • getCopiesAsObjects

      public ArrayList<GObject> getCopiesAsObjects()
      Returns an ArrayList containing all the copied GObject instances currently managed by this CopyProperties object. Each element in the list is the 'copy' part of an original-copy pair.
      Returns:
      An ArrayList of GObject instances that are copies.
    • builder

      public static CopyPropertiesBuilder builder(ArrayList<GObject> objects)
      Creates a new CopyPropertiesBuilder instance for constructing CopyProperties.
      Parameters:
      objects - The initial list of GObject instances to be managed by the CopyProperties.
      Returns:
      A new CopyPropertiesBuilder instance.
    • existsOrElse

      public <T extends CanCopy> T existsOrElse(UUID id, Supplier<T> supplier) throws InvalidCopyException
      Checks if a copy for the given UUID already exists. If it does, returns the existing copy. If not, and soft dependencies are enabled, it creates a new object using the provided supplier, adds it as a copy, and returns it. If not, and soft dependencies are disabled, it throws an InvalidCopyException.
      Type Parameters:
      T - The type of the object, which must extend CanCopy.
      Parameters:
      id - The UUID of the original object to check for.
      supplier - A Supplier to create a new object of type T if it doesn't exist and soft dependencies are allowed.
      Returns:
      An existing copy or a newly created and added copy.
      Throws:
      InvalidCopyException - If the object with the given ID is not found and soft dependencies are disabled. This exception is handled and re-thrown by StaticRefs.getErrs().
      See Also: