interface

How do I find the Java interface whose method is implemented in a given class?

我们两清 提交于 2019-12-13 14:17:08
问题 I need quite the opposite of what most people want to juggle with: I have a StackTraceElement with className and methodName. As the method belongs to an interface given class implements, I need a way I can ask the method which interface it originates in. I can invoke Class.forName(className) and can also invoke clazz.getMethod(methodName) , however method.getDeclaringClass() returns with the mentioned class' name instead of its original interface'. I don't want to iterate through all the

is an abstract class a type of interface?

旧城冷巷雨未停 提交于 2019-12-13 14:13:34
问题 In my /interfaces folder I put all my interfaces. Is an abstract class a type of interface? 回答1: In C#, interfaces are distinct from classes (even abstract classes); interfaces can only define the API (method signatures, event declarations, property declarations), not the implementation (fields, method bodies, etc) you can only inherit one base class, but you can implement multiple interfaces But they have similarities in some usages - for example when used in an abstract factory

Partial Classes, LINQ, Interfaces and VB.NET

心已入冬 提交于 2019-12-13 13:11:17
问题 Okay, I have ran in to a problem with VB.NET. So all those defenders of VB.NET please can you help me out? Here is my issue: I am using LINQ to Entities, it also works with LINQ to SQL, I build my edmx file I then create a Partial Publc Class of the same name as one of the entities All fine up to now, so here comes the problem. I need the Partial class to implement an Interface Implements Interfaces.IAsset But VB.NET want to place "Implements Interfaces.IAsset.ID" at the end of the property,

How can I create an interface in VB.NET with implicit implementations

放肆的年华 提交于 2019-12-13 13:06:33
问题 In C# I can create an interface, and when I use the interface the compiler knows that certain interface requirements are fulfilled by the base class. This is probably clearer with an example: interface FormInterface { void Hide(); void Show(); void SetupForm(); } public partial class Form1 : Form, FormInterface { public Form1() { InitializeComponent(); } public void SetupForm() { } } The compiler knows that Hide() and Show() are implemented in Form and the above code compiles just fine. I can

internal member in an interface

妖精的绣舞 提交于 2019-12-13 12:23:44
问题 I have a list of objects implementing an interface, and a list of that interface: public interface IAM { int ID { get; set; } void Save(); } public class concreteIAM : IAM { public int ID { get; set; } internal void Save(){ //save the object } //other staff for this particular class } public class MyList : List<IAM> { public void Save() { foreach (IAM iam in this) { iam.Save(); } } //other staff for this particular class } The previous code doesn't compile because the compiler requires all

iPhone iOS how to create interactive drag, rotate, resize, delete view control?

我们两清 提交于 2019-12-13 12:17:51
问题 I got an app that allows users to add content to a canvas. I would like to be able to offer the user an ability to move, rotate, resize, reflect this content. Currently I'm doing this with gestures, but would like to know if there is some sort of open-source widget that draws a box around the view and adds 4 buttons to do these functions: rotate 90 degrees rotate freely resize delete Can anyone think of an open source framework that I can add to my project to create controls like the ones

List of Classes implementing an Interface

爱⌒轻易说出口 提交于 2019-12-13 11:43:19
问题 Is there a way to implement something like List<Class<? implements MyInterface>> ClassList = new ArrayList<Class<? implements MyInterface>>(); my goal is to create a hashmap from that list, where the keys are the toString methods of the class (defined in MyInterface) and the values are the classes itself. The toString method of every object of this class returns the same result. This way I could create Instances of the classes using the map by searching the right strings. thank you for trying

Can you override interface methods with different, but “compatible”, signatures?

一世执手 提交于 2019-12-13 11:38:32
问题 Consider the following PHP interfaces: interface Item { // some methods here } interface SuperItem extends Item { // some extra methods here, not defined in Item } interface Collection { public function add(Item $item); // more methods here } interface SuperCollection extends Collection { public function add(SuperItem $item); // more methods here that "override" the Collection methods like "add()" does } I'm using PHPStorm, and when I do this, I get an error in the IDE that basically states

Cannot pass a List<Foo> to a method expecting a List<IFoo>, where Foo : IFoo

大憨熊 提交于 2019-12-13 11:36:28
问题 I have a class Foo implementing the IFoo interface. I have a method taking a List<IFoo> as a parameter. However, it cannot convert from List<Foo> to List<IFoo> - this surprises me, since Foo implements the IFoo interface. How can I get around this, and why does this occur? (Always good to learn from mistakes) 回答1: This is because List<T> is not covariant. For details, see Covariance and Contravariance in C#. If you can make your method work on IEnumerable<T> instead, this will work (you can

How to best test Java code?

佐手、 提交于 2019-12-13 11:34:17
问题 I have been working on a comparatively large system on my own, and it's my first time working on a large system(dealing with 200+ channels of information simultaneously). I know how to use Junit to test every method, and how to test boundary conditions. But still, for system test, I need to test all the interfacing and probably so some stress test as well (maybe there are other things to do, but I don't know what they are). I am totally new to the world of testing, and please give me some