inheritance - Get enum size from parent interface in java -


I have an interface ParentInterface and there are several enforcers to implement it: ChildEnum1 and ChildEnum2 . I have a method that I pass as the ParentInterface parameter.

By which method is passed the ChildEnum , I want to get this size of anonymity How can I do this? The values.length () method works only on enums , but we are going through the caller only in ParentInterface .

How can we achieve it?

with reflection, Dirty demo):

  package com.stackoverflow.so21821751; Public Class Test {Interface ParentInterface {void someMethod (); } Stable enum implements ChildEnum1 ParentInterface {FOO, BAR, LOL; @ Override public zero; some method () {// some}} static enum ChildEnum2 ParentInterface {FOO, BAR; @ Override Public Zero Some Method () {// Some}} Public Fixed Zero Main (Last String [] args) {foo (ChildEnum1.BAR); // 3 fu (hair annam 2.fu); // 2} Private Static Zero Foo (Last ParentInterface i) {System.out.println (i.getClass (). GetEnumConstants (). Length); }}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -