Class ClassRegistry

java.lang.Object
org.apache.tinkerpop.gremlin.structure.io.ClassRegistry

public final class ClassRegistry extends Object
Holds the classes a GraphSON or Gryo Class value may name, so such a name is resolved from this registry rather than by a class loader. Registration is a Java API only and refuses a TraversalStrategy, which belongs to TraversalStrategies.GlobalCache.

lookup(String) also falls back to GlobalCache.getRegisteredStrategyClassByFullName, so a strategy the selector can construct is nameable without being registered here.

  • Method Summary

    Modifier and Type
    Method
    Description
    static Optional<Class<?>>
    lookup(String className)
    Looks up a class nameable as a generic Class value, without loading it.
    static void
    register(Class<?> clazz)
    Registers a class as nameable as a generic Class value, without making it constructible from a serialized traversal, so it cannot widen what the selector can construct.
    static void
    unregister(Class<?> clazz)
    Removes a class from this registry, so it is no longer nameable as a generic Class value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • register

      public static void register(Class<?> clazz)
      Registers a class as nameable as a generic Class value, without making it constructible from a serialized traversal, so it cannot widen what the selector can construct. A TraversalStrategy is refused with an IllegalArgumentException and a null with a NullPointerException.
    • unregister

      public static void unregister(Class<?> clazz)
      Removes a class from this registry, so it is no longer nameable as a generic Class value. A TraversalStrategy is refused because strategies belong to TraversalStrategies.GlobalCache, and a null is refused with a NullPointerException.
    • lookup

      public static Optional<Class<?>> lookup(String className)
      Looks up a class nameable as a generic Class value, without loading it. Matching is on the exact Class.getName(), never assignability, so registering a superclass or an interface does not admit its subtypes. A null name yields an empty Optional, since a Class value can name nothing.