Class SemanticallyEqual

java.lang.Object
org.openrewrite.java.search.SemanticallyEqual

@Incubating(since="7.24.0") public class SemanticallyEqual extends Object
Recursively checks the equality of each element of two ASTs to determine if two trees are semantically equal.

Bug fixes related to semantic equality should be applied to `CombineSemanticallyEqualCatchBlocks$CommentVisitor` too.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areEqual(org.openrewrite.java.tree.J firstElem, org.openrewrite.java.tree.J secondElem)
     
    static boolean
    areSemanticallyEqual(org.openrewrite.java.tree.J firstElem, org.openrewrite.java.tree.J secondElem)
    Compares method invocations and new class constructors based on the `JavaType.Method` instead of checking each types of each parameter.

    Methods inherited from class java.lang.Object

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

    • SemanticallyEqual

      protected SemanticallyEqual()
  • Method Details

    • areEqual

      public static boolean areEqual(org.openrewrite.java.tree.J firstElem, org.openrewrite.java.tree.J secondElem)
    • areSemanticallyEqual

      public static boolean areSemanticallyEqual(org.openrewrite.java.tree.J firstElem, org.openrewrite.java.tree.J secondElem)
      Compares method invocations and new class constructors based on the `JavaType.Method` instead of checking each types of each parameter. I.E. void foo(Object obj) {} invoked with `java.lang.String` or `java.lang.Integer` will return true.