interface

Keep track of all the classes that implement a particular interface?

走远了吗. 提交于 2020-01-02 02:25:11
问题 It's difficult to explain what I really want. I have an interface which has a method getRuntimeInfo() which provides me all the runtime debug information for the variables of a class. I want to see the list of all the classes that implement this interface. I am using Java and Spring. One way I can do this is to get all the beans from the Spring Context and check using the instanceof operator. But i wouldn't want to do that for obvious performance impacts. Do i have some other option? 回答1:

How to implement an interface member that returns void in F#

我怕爱的太早我们不能终老 提交于 2020-01-01 23:59:08
问题 Imagine the following interface in C#: interface IFoo { void Bar(); } How can I implement this in F#? All the examples I've found during 30 minutes of searching online show only examples that have return types which I suppose is more common in a functional style, but something I can't avoid in this instance. Here's what I have so far: type Bar() = interface IFoo with member this.Bar() = void Fails with _FS0010: Unexpected keyword 'void' in expression_. 回答1: The equivalent is unit which is

Interface with only constants

 ̄綄美尐妖づ 提交于 2020-01-01 14:42:01
问题 Recently I came across a piece of code wherein I found an interface with only constants. And those constants were accessed in classes using static imports. The constants were more in number (around 30 to 50). Personally, I don't think it's a good practice. Thats why its called as Constant Interface Antipattern according to Effective Java. I don't find any good reason to go for this kind of coding. Also, static import should be used ONLY if there are few constants to be imported by many

Interface with only constants

瘦欲@ 提交于 2020-01-01 14:41:23
问题 Recently I came across a piece of code wherein I found an interface with only constants. And those constants were accessed in classes using static imports. The constants were more in number (around 30 to 50). Personally, I don't think it's a good practice. Thats why its called as Constant Interface Antipattern according to Effective Java. I don't find any good reason to go for this kind of coding. Also, static import should be used ONLY if there are few constants to be imported by many

A class implements two interfaces. Which interface does a method belong to? [duplicate]

爷,独闯天下 提交于 2020-01-01 09:46:13
问题 This question already has answers here : Implementing multiple interfaces having same method (5 answers) Implementing two interfaces in a class with same method. Which interface method is overridden? (7 answers) Closed 6 years ago . There are two interfaces B and C each having the same method public m1() class A implements B and C If class A has to implement method m1() , the implemented method would be of which interface? 回答1: I think we can say that A.m1 implements both B.m1 and C.m1.

XJC superinterface and superclass only for all classes?

本小妞迷上赌 提交于 2020-01-01 09:00:10
问题 I'm trying to automatically implement an interface in one java class generated from a xsd file. This looks as if it could do that, but it will only add implements SomeInterface to all classes, which is completly stupid. Am I missing something or can you only do this for all classes? Doesn't really make too much sence to let all generated classes implement the same interface. Can I use this feature for one class only? 回答1: You could use Inheritance extension provided by JAXB2 Basics Plugins.

what are the most used interfaces in C#? [closed]

懵懂的女人 提交于 2020-01-01 08:06:16
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago . I tried searching for the most used built-in interfaces in C#, but couldn't find an article, so I thought we may recap here. Let's use

In java 8, why cannot call the interface static method that the current class is implementing [duplicate]

余生长醉 提交于 2020-01-01 07:32:07
问题 This question already has answers here : Why are class static methods inherited but not interface static methods? (4 answers) Closed 4 years ago . I'm playing around Java 8's new features recently and observed an interesting behaviour: This is okay: Class A { static void staticMethodInA() {println();} } Class B extends A {} B.staticMethodInA(); This would induce an error of: static method may be invoked on containing interface class only . interface A { static void staticMethodInA() {println(

Fluent nhibernate: How do I map an entity with a property who's type is an interface?

て烟熏妆下的殇ゞ 提交于 2020-01-01 06:49:09
问题 I have an entity like: public class Employee { public int ID { get; set; } public IAccountManager AccountManager { get; set; } ... } I also have a mapping defined for "DefaultAccountManager" - a concrete implementation of IAccountManager. When mapping the above "Employee" entity, how do I tell NHibernate to persist/load the AccountManager property using the mapping defined in "DefaultAccountManager"? Edit: Actually if I could setup a mapping for IAccountManager so that NHibernate could just

@MustOverride annotation?

给你一囗甜甜゛ 提交于 2020-01-01 04:31:05
问题 In .NET, one can specify a "mustoverride" attribute to a method in a particular superclass to ensure that subclasses override that particular method. I was wondering whether anybody has a custom java annotation that could achieve the same effect. Essentially what i want is to push for subclasses to override a method in a superclass that itself has some logic that must be run-through. I dont want to use abstract methods or interfaces, because i want some common functionality to be run in the