Class ImmutableDetector

java.lang.Object
com.comphenix.protocol.reflect.cloning.ImmutableDetector
All Implemented Interfaces:
Cloner

public class ImmutableDetector extends Object implements Cloner
Detects classes that are immutable, and thus doesn't require cloning.

This ought to have no false positives, but plenty of false negatives.

Author:
Kristian
  • Constructor Details

    • ImmutableDetector

      public ImmutableDetector()
  • Method Details

    • canClone

      public boolean canClone(Object source)
      Description copied from interface: Cloner
      Determine whether or not the current cloner can clone the given object.
      Specified by:
      canClone in interface Cloner
      Parameters:
      source - - the object that is being considered.
      Returns:
      TRUE if this cloner can actually clone the given object, FALSE otherwise.
    • isImmutable

      public static boolean isImmutable(Class<?> type)
      Determine if the given type is probably immutable.
      Parameters:
      type - - the type to check.
      Returns:
      TRUE if the type is immutable, FALSE otherwise.
    • clone

      public Object clone(Object source)
      Description copied from interface: Cloner
      Perform the clone.

      This method should never be called unless a corresponding Cloner.canClone(Object) returns TRUE.

      Specified by:
      clone in interface Cloner
      Parameters:
      source - - the value to clone.
      Returns:
      A cloned value.