English 中文(简体)
以 Java 扩展为共享扩展的通用对象
原标题:Generic Object with shared extends in Java

I m not sure this is possible but I m trying to declare an Object that will act as a Class, Method or Field (mainly just to call getAnnotation()). I thought of trying Object<? extends AnnotatedElement> as they all share that implementation but Object is not a generic type. Is this possible and if not what would be a better approach (besides separate objects for each)?

最佳回答

仅宣布为附加说明。

问题回答

我认为你试图在这里做太多,只是声明你的目标为附加说明

尽可能频繁地使用通用术语固然是令人信服的,但我们绝不应忘记OO的简单、基本结构。 保持重点集中的最好办法是,每当你想出一个看上去过于复杂的结构时,与其在做的工作相比,只要问自己一个问题,“我是否使用正确的工具? ”





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签