Class Traverser

java.lang.Object
com.cedarsoftware.util.Traverser

public class Traverser extends Object
Java Object Graph traverser. It will visit all Java object reference fields and call the passed in Visitor instance with each object encountered, including the root. It will properly detect cycles within the graph and not hang.
Author:
John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Field Details

  • Constructor Details

    • Traverser

      public Traverser()
  • Method Details

    • traverse

      public static void traverse(Object o, Traverser.Visitor visitor)
      Parameters:
      o - Any Java Object
      visitor - Visitor is called for every object encountered during the Java object graph traversal.
    • traverse

      public static void traverse(Object o, Class<?>[] skip, Traverser.Visitor visitor)
      Parameters:
      o - Any Java Object
      skip - String[] of class names to not include in the tally
      visitor - Visitor is called for every object encountered during the Java object graph traversal.
    • walk

      public void walk(Object root, Class<?>[] skip, Traverser.Visitor visitor)
      Traverse the object graph referenced by the passed in root.
      Parameters:
      root - Any Java object.
      skip - Set of classes to skip (ignore). Allowed to be null.