Package com.cedarsoftware.util
Class Traverser
java.lang.Object
com.cedarsoftware.util.Traverser
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
License
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class wraps a class in order to cache the fields so they are only reflectively obtained once.static interface
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
traverse
(Object o, Traverser.Visitor visitor) static void
traverse
(Object o, Class<?>[] skip, Traverser.Visitor visitor) void
walk
(Object root, Class<?>[] skip, Traverser.Visitor visitor) Traverse the object graph referenced by the passed in root.
-
Field Details
-
_classCache
-
-
Constructor Details
-
Traverser
public Traverser()
-
-
Method Details
-
traverse
- Parameters:
o
- Any Java Objectvisitor
- Visitor is called for every object encountered during the Java object graph traversal.
-
traverse
- Parameters:
o
- Any Java Objectskip
- String[] of class names to not include in the tallyvisitor
- Visitor is called for every object encountered during the Java object graph traversal.
-
walk
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.
-