If I have something like
public class OwnerClass1{
public class OwnedClass{
// definition 1
}
}
public class OwnerClass2{
public class OwnedClass{
// definition 2
}
}
From a function that is implemented as below:
public <OwnedClass> boolean doStuff(OwnedClass example) {
System.out.println(example.<???>);
// example.getClass() returns "OwnerClass1$OwnedClass" etc here, so I guess getting this to string and trimming after $ would be one solution
// example.getSuperClass() returns "java.lang.Object" here, so not what I need
}
How can I get the behavior as below:
doStuff(new OwnerClass1.OwnedClass());
// OwnerClass1
doStuff(new OwnerClass2.OwnedClass());
// OwnerClass2
Note: Code above is meant to give a rough idea of the structure, not to be compiled out of box.