jeudi 12 avril 2018

detecting logically duplicate classes under different class hierarchies in java

I have some Entity classes with following structure.

class A {
    ... other fields.
    static class B {
        String field1;
        int field2;
        C fieldC;
        static class C {
            String field3;
        }
    }
}

class X {
    ... other fields
    static class B {
        String field1;
        int field2;
        C fieldC;
        static class C {
            String field3;
        }
    }
}

Note: I have no control over this source code and cannot change its structure.
Now, I am generating a client for these entities and I want to detect that class B is actually the exact same class, under 2 different hierarchies. I have the java.lang.reflect.Type instance of both these B classes. So, with that, how is it feasible to detect that these are indeed logical duplicates. If I can detect that, then at the client side, I actually only need to generate 1 class hierarchy for this.
Particularly challenging for me is the subclass C. Any libraries that can do this?





Aucun commentaire:

Enregistrer un commentaire