java - Enforce subclass to declare a enum -


Can I apply child classes to create a NAM in them?

  class document & lt; T Enum & lt; T & gt; & Gt; {Map & lt; T, String & gt; Farm; } Class text document document & lt; TextDocument.Field & gt; Expands {public enum field {...}}   

How can I apply any implementation of the document to an enum named field? In the above example, text documents can increase the document with some other enum (like GraphDocument.Field) which should not be allowed. How can I make this restriction? I need to apply this rule in subclasses - "You should have your own enumeration" Is this also possible? Some hack way? any idea?

In short, you can not, however, you return it to an array of values ​​of a particular calculation Can be bound to You can also force the calculation to implement the interface.

  Public Interface Some interfaces {// Any method that you want to be able to perform on enums} Public Essentials Class SomeSuperClass & lt; T some interface & gt; {Abstract t [] getSome (); } Public Class Some Shoqualas Some SomeuperClass & lt; SomeInterface & gt; {Public Enemy Some Enemails Applys Some Interfaces {testEnum {// Interface Implementation}} Public Some Interface [] getSome () {SomeEnum.values ​​(); }}   

This is a very strange solution, but it works.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -