Class DoubletDigger

java.lang.Object
clazzfish.monitor.internal.DoubletDigger

public final class DoubletDigger extends Object
The DoubletDigger looks for classes which appears more than once in the classpath.

Originally the class was part of the PatternTesting project where it was located in the ClasspathMonitor till v0.6.1. But it gets too big so it was extracted to its own class.

Author:
oliver
  • Constructor Details

    • DoubletDigger

      public DoubletDigger(ClasspathDigger classpathDigger)
      Instantiates a new doublet digger.
      Parameters:
      classpathDigger - the classpath digger
  • Method Details

    • reset

      protected void reset()
      Resets the doubletList and maybe later other things. At the moment it is only used by ClasspathMonitorTest by the testGetDoubletListPerformance() method.
    • isDoublet

      public boolean isDoublet(Class<?> clazz)
      Is the given class a doublet, i.e. can it be found more than once in the classpath?

      Note: Because this method is needed by other methods like getIncompatibleClassList() in the ClasspathMonitor the result of it is cached. This speeds up this method about the factor 2000 and more:

       Implementation | Mode  | Score    | Unit
       ---------------+-------+----------+-------
       old (till 1.4) | thrpt |    35514 | ops/s
       new (cached)   | thrpt | 92968300 | ops/s
       

      This results were calculated with the help of JMH and was executed on a Dell Latitude e6520 with i5 processor (i5-2540M CPU @ 2.60GHz).

      Parameters:
      clazz - the class to be checked
      Returns:
      true if class is found more than once in the classpath
    • isDoublet

      public boolean isDoublet(String name)
      Checks if is doublet. If a resource appears with the same URI in the classpath this is not considered as classpath, only if it is a real doubliet.
      Parameters:
      name - the name
      Returns:
      true, if checks if is doublet
    • getDoublet

      public URI getDoublet(String name, int nr)
      Gets the doublet.
      Parameters:
      name - the name
      nr - the nr (starting at 0)
      Returns:
      the doublet
    • getDoublet

      public URI getDoublet(Class<?> clazz, int nr)
      Gets the doublet.
      Parameters:
      clazz - the clazz
      nr - the nr
      Returns:
      the doublet
    • getDoubletClasses

      public String[] getDoubletClasses()
      Gets the doublets.
      Returns:
      the doublets
    • getDoubletResources

      public String[] getDoubletResources()
      Gets the doublet resources.
      Returns:
      the doublets
    • getDoubletClassList

      public List<Class<?>> getDoubletClassList()
      Gets the doublet list.
      Returns:
      the doublet list
    • getDoubletResourceList

      public List<String> getDoubletResourceList()
      Gets the doublet list.
      Returns:
      the doublet list
    • toString

      public String toString()
      To string.
      Overrides:
      toString in class Object
      Returns:
      the string
      See Also:
    • isMultiThreadingEnabled

      public boolean isMultiThreadingEnabled()
      Is multi threading enabled? Multi threading is automatically enabled if more than one processor is found. Otherwise you can use set via the system property "multiThreadingEnabled=true" to activate it.
      Returns:
      true if multi threading is enabled for this class.
    • setMultiThreadingEnabled

      public void setMultiThreadingEnabled(boolean enabled)
      Here you can enable or disable the (experimental) multi threading mode to see if it is really faster on a mult-core machine.
      Parameters:
      enabled - true or false