FAQ Database Discussion Community


How do I calculate PCIe 1x, 2.0, 3.0, speeds properly?

performance,interface,hardware,pci-e
I am honestly very lost with the speeds calculations of PCIe devices. I can understand the 33MHz - 66MHz clocks of PCI and PCI-X devices, but PCIe confuses me. Could anyone explain how to calculate the transfer speeds of PCIe?...

Java Interfaces Casting

java,interface,casting
Imagine we have class C that implements interfaces I and J declared as ; I i = new C(); why do these 3 not give errors (especially the last one): 1) C c = (C)i; 2) J j = (J)i; 3) i = (I)null; thanks in advance. ...

How to correctly handle a list made of generic classes with methods that also have generic returns

c#,json,generics,interface,abstract-class
I believe this question is answered simply, but since I've been banging my head on this issue for a while, I've might have trouble seeing the overall picture. I want to load multiple files (in this case, JSON), so I created a DataLoader class that will handle this. In this...

Java: Implementing an interfacing by inheriting a class

java,inheritance,interface,casting
Time-appropriate greetings :) Working in Java, I have an Interface A. All implementors of this Interface also extend class B, but B does not implement A. In a class where we use an instance of A (referenced as A), it is cast to a B Reference so that we can...

Why can i change an implementation of property defined in interface in the class

c#,.net,oop,interface
I am trying to understand that if I create an interface ITest which defines one property Version with only getter in it. Then when I implement this interface in Test class I can change the definition of the property to getter and setter. How can i change the implementation of...

Variables in java interfaces

java,variables,interface
I made a java interface called Polygon, it contains various abstract methods like getArea() and getNVertices(). It will be implemented by subclasses such as Triangle, Quadrilateral etc. which in turn are extended (e.g., Quadrilateral is extended by Rectangle). Now each Polygon will be defined by a number of vertices (I...

interface generic return type

c#,generics,interface
I have serveral classes with similar method signatures that I wish to capture in an interface: namespace MyLib public class ClientList public ICollection<Client> Fetch() { { //do stuff return this.CreateCollection(); } private ICollection<Client> CreateCollection() { List<Client> clientList = new List<Client>(); // populate list return clientList; } public class ProductList public...

Focus control in a frame

delphi,interface
I hope I can explain wich is the prblem i'm trying to solve. I've a form with 3 papnels: 1 for buttons, 1 for data, and 1 for messages. The data panel is populated with some frames (one for each database table I need to use). The table detail frame...

“Attempting to use an incompatible return type” with Interface Inheritance

java,inheritance,interface
I'm running into a problem with incompatible return types using inheritance. public interface A { } public interface B extends A { } public interface C { Map<String, A> getMapping(); } public interface D extends C { Map<String, B> getMapping(); } Is there a way to make this work? Right...

Golang switch between structs

struct,go,interface,switch-statement
I'm new to golang and I'm trying to create a function that, based on the struct it's used on, will return a formatted string using Sprintf type Name struct { Title string First string Last string } type Location struct { Street string City string State string Zip string }...

Static interface equivalent C#

c#,inheritance,interface,static
I've worked with singletons in the past and I'm aware it's a solution for some people who are trying solve the static interface problem. In my case, I can't really use a singleton because I have an external class that I'm inheriting from and I have no control over this...

interfaces having same function prototype in java? [duplicate]

java,interface
This question already has an answer here: Method name collision in interface implementation - Java 6 answers I have implemented two interfaces with same method names and signatures in a single class then how the compiler will identify the which method is for which interface? E.X: public interface Hourly{...

Declare interface in static context(for example in static block) in java?

java,interface,static-block
for example public class Test { static { interface ITest {} } } Here the interface ITest is declare within the static block... The purpose is to know why this happening and not what is happening.. Interfaces are inherently static then why it can not be declared in static block...

How can you test if one class implements all the interfaces of another?

c#,interface,components
I'm using C# and Unity. I have classes that I add as components to other classes, and some of these components depend on each other. I was hoping to find a way to iterate through all of the interfaces of the component, and test the class to which it's being...

Utility method expects interface and doesn't accept a class that implements said interface [duplicate]

java,interface
This question already has an answer here: Why we can't do List<Parent> mylist = ArrayList<child>(); 2 answers I'm working on a web development project, and I'm working on several apps with "news feed" functionality. I want to make sure that every item with a picture flips a switch back...

Meaning of “this [int index]”

c#,.net,interface
In C# we have the following interface: public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable { T this [int index] { get; set; } int IndexOf (T item); void Insert (int index, T item); void RemoveAt (int index); } I don't understand the line T this [int index] { get; set;...

Can a method implement multiple interface methods?

c#,interface
These are two implementations of interface methods and as you can see, they do the same thing in this case. public override IList<IDatastoreRequestParameter> GetReadByOwnerIdParameters(int id) { return new List<IDatastoreRequestParameter> { new DatastoreRequestParameter("@CustomerId", id) }; } public override IList<IDatastoreRequestParameter> GetDeleteByOwnerIdParameters(int id) { return new List<IDatastoreRequestParameter> { new DatastoreRequestParameter("@CustomerId", id) }; }...

Is it possible to automatically chose the appropriated class method when having an interface argument?

java,class,interface,overwrite,generic-type-argument
Ok, so I have searched and I couldn't find the answer to this particular question. It's possible that this is a recurrent problem and I don't know the right terms to refer to it, so all help is appreciated. :) Lets say we have a method m0 which receives an...

Sort a set and assign the content to a List in java

java,interface,implements,java-generics
I have the following java test code that I want to implement: import java.util.*; public class TestRisorseWeb { public static void main(String[] args) { RisorsaWeb p = new PaginaWeb("index.html","<html><body>main</body></html>"); // name and content java.io.File f = new FileWeb("pippo.txt","Questo e' il contenuto\ndi un file di testo."); assert f instanceof RisorsaWeb; Set<RisorsaWeb>...

What's the purpose of including java.lang.Object in an interface's Constant Pool?

java,interface,jvm,bytecode,jvm-hotspot
Compiling the following interface: package test; public interface MyInterface { public void foo(); } and checking the compiled code using javap -v -s test.MyInterface shows the following (-s prints member signatures): Compiled from "MyInterface.java" public interface test.MyInterface SourceFile: "MyInterface.java" minor version: 0 major version: 51 flags: ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT Constant...

Bounding type parameters of generic methods with interfaces?

java,generics,methods,interface,generic-method
So I have 2 versions of the same method. Version 1: public static <T> int countGreaterThan(T[] anArray, T elem) { int count = 0; for (T e : anArray) { if (e > elem) count++; } return count; } Version 2: public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T...

How's Python today concerning Interfaces for documentation purposes?

python,interface
I've read this post from a long time ago and I've tried to create my own trivial example: class IExample(Interface): """ An object that serves as an Example.""" class IExamp(IExample): """ Examp object representing the current state of Example.""" def set_state(state): """ Sets the state of Example.""" def get_state(): """...

How to implement repeated behavior when inheritance isn't an option

java,oop,interface
I have two classes which share some properties and behavior. One such cluster of common behavior is manipulation in 3D space. As such, each implements interface Transformable: public interface Transformable { public void position (double x, double y, double z); public void position (Tuple3d tuple); public void rotateDeg (double yaw,...

Implement method for class in a different class

java,interface,lambda
There is a class A which has an undefined method called OnEvent. I want this method to be define by the class that instantiates a class A Object. Like this: public class A{ int someVar=1; float anotherVar=2; public void method1(){ ... if( event ) OnEvent(); ... } //OnEvent is not...

CI accessing property on interface

php,laravel,interface,scrutinizer
I'm using scrutinizer to analyze my code. And almost everything has been fixed but I can't seem to fix this issue. Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check? I see the problem beceause it's an interface that...

How to access attribute of interface

interface,go
It was my intention to use the HTTP status codes both in the header and the body of the two response structs. Bu that without setting the status code twice as function parameter and again for the struct to avoid redundancy. The parameter response of JSON() is an interface to...

Populating Interface

c#,interface,implements
Can anyone tell me how do I populate my fields in my interface IAccount? I'm having an error in x.Add(new IAccount ... public class IPersonRepo : IAccount { string connectionstring = @"Server=SLI002/SQLEXPRESS;Database=atengturonDB;Trusted_Connection=true;"; public int AccountsID { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public...

Fighter class does not implement interface member

c#,class,interface
And I am getting this error: Error 1 'Fight.Fighter' does not implement interface member 'Fight.IFighter.Utok(Fight.IFighter)' This is the first time I am trying to learn working with interfaces, so sorry for dump question. Any ideas? I have following code: Interface: interface IFighter { string GraphicLife(); bool IsLive(); int Obrana(int utocneCislo);...

Android pass arguments from dialog to calling activity

java,android,interface
I'm having problems getting data from my dialog to the calling activity. Been following the android documents, but haven't had luck. I just want to capture a string that someone enters in an edit text box of my dialog. Here is my setup. public class CrossoverMainActivity extends Activity implements CrossoverSaveDialog.NoticeDialogListener...

How to apply more constraints on an interface declaration in Java?

java,generics,interface
Let's say I have following interface: interface Mammal { void marry(Mammal m); Mammal giveBirthTo(); } However, this doesn't say quite exactly what I want. Obviously, a human can't marry a dog, nor give birth to a cat. So how can I embed this information into the interface, such that the...

navigate to back page in page based interface on event programmatically

objective-c,interface,navigation,watchkit
My application is page based, i want on one event my app swipe to left page programmatically.i tried using becomeCurrentPage method but how to use it in this case. please help. any suggestions will be appreciated. Thanks

Java Generic Interface vs Generic Methods, and when to use one

java,generics,methods,interface,parameterized
I was wondering, aside from syntactic difference, when would one use a generic interface over a method that accepts a generic parameter? public interface Flight<T>{ void fly(T obj); } over public interface Flight{ void <T> fly(T obj); } ...

Interface for Child Class that Inherits from parent class without reimplementing parent class

c#,oop,inheritance,interface
Currently I have the following: public class ChildClass : ParentClass {... ParentClass implements an interface as follows (I need ParentClass to be instantiated and therefore can't be abstract): public class ParentClass : IParentClass {... I also want child class to implement an interface so that I can mock this class...

How it is possible to call methods of Object class on a reference of Interface type?

java,interface
interface TestInterface{ public void sayHello(); } class A implements TestInterface{ public void sayHello(){ System.out.println("Hello"); } public void sayBye(){ System.out.println("Hello"); } public String toString(){ return "Hello"; } public static void main(String args[]){ TestInterface ti=new A(); ti.sayHello(); ti.sayBye();//error ti.toString();//How toString method can be called as it is not the part of the...

Avoiding type checking when interface method parameters are abstract

c#,oop,interface
My interface looks like this: public interface UserHandler { CheckUsernameResponse CheckUsername(CheckUsernameRequest request); } The request and response types in the signature are abstract classes, giving a usage of something like: var fooHandler = new FooUserHandler(); var fooResponse = fooHandler.CheckUsername( new FooRequest { id = 1, FooProperty = "abc" }); or...

unable to start activity from onPostexecute() using interface

android,interface,android-asynctask
I need to start another activity from the onPosExecute method of the AsyncTask. The AsyncTask is a seperate class and not in any activity class. I have used an interface to do so. The codes are: This is the onPostExecute() method @Override protected void onPostExecute(String json) { Log.v("JSON", json); Log.v("updateUI",""+updateUI);...

subclass of thread implementing Runnable interface

java,multithreading,oop,interface,runnable
It confuses me why a subclass of thread that implements a runnable interface doesn't force me to override the run method. Basically, when i create simple class that implements Runnable it forces me to override the run method. But when i made the ordinary class a subclass of thread, it...

Box C# object as generic interface

c#,generics,interface
I have a significant amount of viewmodels, each designed for one specific object type (e.g. Person, Car, whatever). I would like to add generic functionality to these, e.g. the ability to check if a viewmodel already exists that contains a specific object (contains a specific Car, Person, etc.). I'd like...

Dependency injection using IOC (Inversion of Control)

c#,interface,dependency-injection,nullreferenceexception
I've Interface public interface IDatabase { void AddRow(string table, string value); } It's implemented on public class Database : IDatabase { public void AddRow(string table,string value) { } } Now here I'm doing Dependency Injection public class CustomerRepository { private readonly IDatabase _database; private readonly string ss; public CustomerRepository() {...

Get List of Elements in Tree with specific Field Value

vb.net,linq,properties,interface
I have an Interface like this: Public Interface TreeSelectorAttributes Property selectedInTreeSelector As Boolean Property Name As String ReadOnly Property childs As IEnumerable(Of TreeSelectorAttributes) End Interface and I have a TreeView which has a List of this TreeSelectorAttributes: Public Property rootList As IEnumerable(Of TreeSelectorAttributes) now after the User chooses which elements...

Interface constant declaration example in Java's SDK

java,interface,constants
Is there an example of an Interface in Java's built-in library (JDK) that contains a constant field? From the documentation, constant declaration can be defined in interfaces, but I can't remember seeing such. public interface OperateCar { // constant declarations, if any ... } ...

Why can't the interface be implemented with pointer receivers

pointers,interface,go
I'm confused as to why this fails to compile with: impossible type assertion: Faz does not implement Foo (Bar method has pointer receiver) if I make the receiver for Faz.Bar a Faz value rather than a Faz pointer then it compiles fine, but I thought it was always better to...

Go: factory returning pointer and interface{} type

interface,go,factory
Consider the following factory: Go playground type TypeA struct { placeholder int } func NewTypeA() *TypeA { return new(TypeA) } func main() { factory := make(map[string]func() interface{}) factory["TypeA"] = NewTypeA } This gives me the following error: cannot use NewTypeA (type func() *TypeA) as type func() interface {} in assignment...

What are the advantages of explicit interface implementation in C#? [duplicate]

c#,inheritance,interface,implementation
This question already has an answer here: C# Interfaces. Implicit implementation versus Explicit implementation 11 answers C# supports built-in mechanism for differentiating methods that have the same names. Here is a simple example below shows how it works: interface IVehicle{ //identify vehicle by model, make, year void IdentifySelf(); }...

If we cannot create an instance of an interface in Java and arrays are nothing but Objects. Then, How is it possible to create Array of interface?

java,arrays,interface
I was going through a code, which really got me confused. interface Interviewer{ void conductInterview(); } class Employees { String name; } class HRexecutive extends Employees implements Interviewer{ String[] Specialization; public void conductInterview(){ System.out.println("HR conduct interview"); } } public class paractise1 { public static void main(String[] args) { Interviewer interviewers...

C# How i use linq with explicit interface attribute?

c#,linq,inheritance,interface,explicit
i have one class with two inheritance interfaces and yours attributes are explicits because both have some equals attributes, so, i need use LINQ with this class, but i can't access the explicits attributes when i use "select new Foo" ... look the case: public class QuestaoMontaProva : IQuestao, IExercicio...

OOPS Concepts: What is the difference in passing object reference to interface and creating class object in C#?

c#,class,interface
I have a class, CustomerNew, and an interface, ICustomer: public class CustomerNew : ICustomer { public void A() { MessageBox.Show("Class method"); } void ICustomer.A() { MessageBox.Show("Interface method"); } public void B() { MessageBox.Show("Class Method"); } } public interface ICustomer { void A(); } I am very confused between these two...

Generic Interface missing implementation

vb.net,interface,implements,generic-interface
I have a generic interface, even if I state the type when I implement it, it says the implemented classes misses all implementation of members. The interface Interface IBuilder(Of T) Function Number(ByVal literal As String) As T End Interface The implement Class BracketsBuilder Implements IBuilder(Of String) Public Function Number(number__1 As...

Decode arbitrary JSON in Golang

json,dictionary,interface,go,unmarshalling
I have a question about decoding arbitrary JSON objects/messages in Go.. Lets say for example you have three wildly different JSON objects (aka messages) that you can receive on an http connection, lets call them for sake of illustration: { home : { some unique set of arrays, objects, fields,...

Are interfaces a valid substitute for utility classes in Java 8? [duplicate]

java,class,interface,java-8,utility-method
This question already has an answer here: Java 8: Interface with static methods instead of static util class 4 answers For the past decade or so, I've been using the pattern below for my Java utility classes. The class contains only static methods and fields, is declared final so...

Matlab - Constructor doesn't initliaize member values

matlab,variables,interface,constructor
Dear lovely community, I already looked in Google and in the forum and also found some interesting posts. But in the end I still didn't get it worked. So, I am going to post the question here. I know in Matlab are already get/ Set methods implemented, but I am...

Singleton and Interface implementation

c++,interface,singleton
I have an interface class Interface with pure virtual methods. class Interface { public: virtual void DoSomething() = 0; } Also, there is a class Implementation that implements the interface. class Implementation : public Interface { void DoSomething(); } In my program I need to have a Singleton (single instance)...

Why is interface variable instantiation possible?

c#,variables,interface,instance
As far as I know, interfaces cannot be instantiated. If this is true, why does the below code compile and execute? It allows you to create a variable interface. Why is this possible? Interface: public interface IDynamicCode<out TCodeOut> { object DynamicClassInstance { get; set; } TCodeOut Execute(string value = "");...

Controller with same structure not working using an interface

c#,asp.net-mvc,interface,datacontext
I have created 8 models and controllers respectively for my Project using the same structure, however now this structure is not working. It is giving me this error: The current type, HelpDesk.Contracts.Repositories.IRepositoryBase`1[HelpDesk.Model.Knowledgebase], is an interface and cannot be constructed. Are you missing a type mapping? Here is my interface: namespace...

What text (in English) should I use when asking the user to overwrite a document? [closed]

interface,messagebox,human-readable
I write a lot of applications in C# and I'm trying to sew up some holes in my standard practices. Specifically, I'm trying to decide on the best text to use in a message box, and I thought I'd ask the StackOverflow community since I believe that many opinions are...

what does “other” mean in Java?

java,object,interface,comparable
I have this code, but I fail to understand what "other" actually is, and what it's trying to do. public interface Comparable<T> { int compareTo(T other); } What is they parameter "other" supposed to mean?...

Why does a callback method needs to return something? [on hold]

java,interface,callback,return-value
I have never before seen such a thing, so let's say I have such listener object: MyWhateverListener dafuqListener = new MyWhateverListener() { @Override public void onSuccessCall(String s) { // success call } @Override public void onFailCall(boolean b) { // fail call } @Override public boolean onDafuqCall(int i, boolean b) {...

Don't understand composition in Go

struct,interface,go,composition
In the example below I've embedded http.ResponseWriter into my own struct called Response. I've also added an extra field called Status. Why can't I access that field from inside my root handler function? When I print out the type of w in my root handler function it says it's of...

Android Fragments fundamentals: why? Is this conceptually wrong?

android,interface,fragment,communication
I bring you a question about "proper programming" in Android. I am currently developing an app using fragments. It involves dynamically added fragments to Activity, fragments inflated from XML, nested fragments from XML or dynamically added. Let's just say, a bit of everything. The concept this question focus is the...

How are interfaces used in the code example 11.1 from the book The Way to Go?

interface,go
I am learning Go and am trying to fully understand how to use interfaces in Go. In the book The Way to Go, there is an example listing 11.1 (pages 264-265). I feel that I am definitely missing something in my understanding of it. The code runs fine, but I...

Extending an interface

java,interface,extends
I downloaded a code that has a function that starts like this: public class MDP<S, A extends Action> implements MarkovDecisionProcess<S, A> { //some code...blah blah blah... } S and A are supposed to be some kind of type. Action is an interface. In my code, I want to use the...

Searching for an example of class-binding by a interface

java,interface,mvp
I am trying try to implement a MVP-Pattern example in Java but I do not know how the interface connection between the Presenter and the View works! Does someone know a good example of this? More details: In some sources a class diagram looks like this diagram The arrow between...

Assigning a concrete Task to a variable of type Task

c#,inheritance,interface,casting,task-parallel-library
Consider a class Foo which wholly implements IFoo. Concurrently, consider a task Task<IFoo>. Why is it that when the following is called, a compilation error is thrown; Task<IFoo> task = Task.Factory.StartNew(() => new Foo()); The compiler states that it cannot convert from source type Task<Foo> to Task<IFoo>. While this makes...

Creating interface for concrete class with enum C#?

c#,interface,dependency-injection,enums,separation-of-concerns
Pardon any mistakes, this is one of my first questions. I would really appreciate some guidance here. I tried searching for previous questions, but I couldn't quite word the question correctly. I'm trying to create a simple Logger with an interface class, but I want to have the interface and...

How to Find a class in external reference that implements certain interface?

c#,visual-studio-2013,interface,reference
I'm working on a project where I have added an external reference. I have searched through this reference with the object explorer. I have found an interface with a function I would like to use. Now to implement an interface you will need a class which have all the functions...

I'm completely lost on how to use keylistener in my java program

java,interface,keylistener
I have a whopping amount of code that I don't know how to implement key listener into. Basically, I wanted the key listener to detect a key press like "w" and change some fields (width and length), in which the program will interact with it. I have a boatload of...

Custom Listener on Button click in ListView Item

android,listview,interface,listener,baseadapter
I have created a Custom Listener interface for Button click in Adapter class, i followed this tutorial: http://www.c-sharpcorner.com/UploadFile/9e8439/create-custom-listener-on-button-in-listitem-listview-in-a/ Adapter: holder.btnQtyIncrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (customListner != null) { customListner.onButtonClickListner(position); } cart = cartArrayList.get(position); holder.textViewQuantity.setTag(cart); if(cart.getQuantity() == 9) { Toast.makeText(context, "Already...

Issue with interface and parameter

java,parameters,interface
I have problem with interface and parameters: public class Functions { public static Double getInfoSum(TreeMap<String, Iinterface> map){ ....some counting } } public class ExampleClass { private TreeMap<String, ExampleClassItem > xxxx; public static void SomeFunction(){ Functions.getInfoSum(xxxx); //HERE IS ERROR } } public class ExampleClassItem implements Iinterface { ..... } Is there...

Methods defined in an interface can no be used from another class

c#,entity-framework,interface
I am using Entity Framework 4.1 and code-first approach. I have the following intefaces namespace BackupCore.Contracts { public interface IEntity { DbSet getDbSet(BackupCoreContainer context); bool isNew() ; } } namespace BackupCore { interface IDao<IEntity> { IEntity Save(IEntity ent); IQueryable<IEntity> GetAll(); bool Delete(IEntity ent, out String errMsg); void SaveChanges(); } }...

Overloading inside interface in Java

java,interface,overloading
I need to implements various update methods for Observers in my project, to overload the Object argument with a specific type. So instead of using public void update (Observable o, Object arg0){ if(arg0 instanceof Class1) .... else if (arg0 instanceof Class2) .... or a switch (which is a very 'C'...

Cannot implicitly convert Lazy to Lazy

c#,interface,initialization,lazy-initialization
I am coding a MVC 5 internet application and I have a question in regards to using an interface with Lazy<T> initialization. Here is the class definition in question: public class WebAPITokenService1_0 : IWebApiTokenService Here is my code that works with out using the interface in the declaration: Declaration: Lazy<WebAPITokenService1_0>...

How to determine dynamically if type is an Interface using reflection?

c#,reflection,interface
For starters, this question is not a repeat of this post that I have read 100 times (please read on for question): How to determine if a type implements an interface with C# reflection I'm using reflection to iterate through properties on objects dynamically at runtime to manipulate and add...

SDK Error while trying to add caching to KMS

php,amazon-web-services,interface
I am getting the following error Fatal error: Uncaught exception 'Aws\Common\Exception\InvalidArgumentException' with message 'Unable to utilize caching with the specified options' in vendor/aws/aws-sdk-php/src/Aws/Common/Credentials/Credentials.php:305 Stack trace: #0 vendor/aws/aws-sdk-php/src/Aws/Common/Credentials/Credentials.php(113): Aws\Common\Credentials\Credentials::createCache(Object(Aws\Common\Credentials\RefreshableInstanceProfileCredentials), Object(Illuminate\Cache\ApcStore), 'credentials_214...') #1...

Why does AbstractCollection implement both Iterable and Collection?

java,collections,interface
AbstractCollection implements both the Iterable and Collection interfaces. However, Collection is a subinterface of Iterable. Would it not suffice just to have AbstractCollection implement Collection?

Access interface variables defined in method

java,methods,interface
I'll just paste the code then explain what I need. I'm lost as to how to acheive this, and I can't even think of alternatives that fit my code very well. public Transform findById(final int id) { final Transform returnTransform = null; execute(new IExecutor() { Transform returnTransform = null; @Override...

Cannot convert type via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

c#,interface,type-conversion
In C#, if I have a parameter for a function where the parameter type is of an interface, how do a pass in an object that implements the interface. Here is an example: The parameter for a function is as follows: List<ICustomRequired> The list that I already have is as...

HuggableInterface in PHP and PSR-8

php,interface
On the PHP Framework Interop Group site (the maintainer of PSRs), there is a draft PSR-8 Huggable Interface: namespace Psr\Hug; /** * Defines a huggable object. * * A huggable object expresses mutual affection with another huggable object. */ interface Huggable { /** * Hugs this object. * * All...

Anonymous types for simple interfaces with only one implementation

c#,.net,interface,anonymous-types
Let's suppose I have the following the interface: public interface IMyInterface { A MyA { get; } B MyB { get; } C MyC { get; } } A, B and C are three non-related classes, and don't implement IMyInterface in any way. Let's suppose now that I will only...

How do I enumerate all string properties in an interface?

delphi,interface,delphi-xe7
I want (if possible) to enumerate all string properties in an interface that looks like this: IXMLDocumentSummaryType = interface(IXMLNode) ['{AD394EAD-1253-4CA5-9F0A-76122CB53D88}'] { Property Accessors } function Get_Uid: UnicodeString; function Get_RsUid: UnicodeString; //etc { Methods & Properties } property Uid : UnicodeString read Get_Uid write Set_Uid; property RsUid : UnicodeString read Get_RsUid...

Accessing objects through their interfaces

c#,interface
What does it really mean? I am reading design pattern book. It says objects are accessed solely through their interfaces, and i am not able to get my head around it, can some body give me some example (Will really appreciate if its in C#) What does we really achieve...

How do I deserialize this JSON string back to a List?

c#,json,list,serialization,interface
I am wanting to be able to use JSON to serialize and deserialize a List<T>, where the type is an interface. I have the code working to serialize the List<T> to a string, but am not sure on how to deserialize the JSON string back into a List<T>. Here is...

Java: Abstract classes methods and interface

java,interface,abstract
The program below calculates the total of the areas of any number of shapes instantiated. The problem is that I don't know how to output the draw() method of the interface. Here is the main class: public class MyClass1{ public static void main(String[] args) { Shape[] shapes= new Shape[3]; shapes[0]=...

IS vs. AS vs. IsAssignableFrom - What are the differences when checking for objectTypes and Interfaces?

c#,performance,object,interface,operators
I'm sort of new to C# and i was wondering if you could help me out. The scenario: public bool ObjectImplementsSpecificInterface (object obj) { // 1. if (obj is IExampleInterface) { return true; } // 2. var tmp = obj as IExampleInterface; if (tmp != null) { return true; }...

Laravel Interfaces

php,laravel,interface,namespaces
I used the following tutorial to get an idea about interfaces: http://vegibit.com/what-is-a-laravel-interface/ But I wanted to change the directory of where I am putting my interfaces to "App/Models/Interfaces". And so I did. But now I cannot get it to work anymore. Here is my code: Routes.php App::bind('CarInterface', 'Subaru'); Route::get('subaru', function()...

How can you force a class that implements a interface also extend an other class?

java,multithreading,interface,extends
Is it possible to make a class that implements my interface to automatically also extend another class? More specific I want my implementation always to be an extension of Thread. Or for that matter implementing Runnable, but public interface Name implements someInterface seems so wrong... public interface userValidTimer extends Thread...

Scapy - the interface of a sniffed packet

python,interface,scapy
I'm sniffing with scapy 2.2 on Windows 7 with Python 2.6. Is there a way I can recognize the interface of a sniffed packet? I thought about using the mac address to identify it, but is there a way to do it with scapy? something like this (doesn't work) -...

How to Call Adapter class before Activity

android,android-activity,android-listview,interface,baseadapter
Log says: D/CartActivity-onCreate(18171): onCreate D/CartActivity-TOTAL-InsideFORLOOP:(18171): 0.0 D/CartActivity-onResume(18171): onResume D/CartAdapter-TOTAL:(18171): 12.95 As you can see in above Log for loop is executed first in CartActivity and after the execution of onResume() method of CartActivity, CartAdapter is executing this line, therefore for i am getting 0.0 as value of Total in CartActivity...

Handling a big interface

android,xml,interface
I'm currently programming an app, but I'm still new to android studio. ![Interface]: http://imgur.com/sofBtth That's the interface I'm working on, but it seems to be too large to use it properly (there are still fields like address, phone, etc. and 2 buttons under the last one that can't be seen)....

How to use Java Interfaces like this?

java,interface,bukkit
I'm working on a program and I want to use interfaces. Something like the way Bukkit used for their Player class, here. I've watched and read tutorials on interfaces multiple times and even tried testing by myself with no luck. Let's say that I have a "User" interface, with a...

Error that I must implement a function in a class even though function is defined [duplicate]

vb.net,class,interface,interface-implementation
This question already has an answer here: Class 'QueryParameterComparer' must implement Function Compare. 1 answer I get the error: Class 'QueryParameterComparer' must implement 'Function Compare(x As QueryParameter, y As QueryParameter) As Integer' for interface 'System.Collections.Generic.IComparer(Of QueryParameter)'. On this class definition: Protected Class QueryParameterComparer Implements IComparer(Of QueryParameter) Public Function Compare(x...

I need to create an interface in c# and a method to load a list of the interface

c#,linq,interface,lambda
Having the two class/inteface below: [Schema("dbo")] [Alias("Team")] public class Team : IHasId<int> { [Alias("TeamId"), AutoIncrement] public int Id { get; set;} [Required] public string TeamName { get; set;} [Required] public DateTime CreatedOn { get; set;} [Required] public int DivisionId { get; set; } [Required] public bool IsActive { get; set;...

Java interface and Exception

java,exception,interface
I have a question in my exam paper where it asks me to write the following interface: <interface> Queue size(): int isEmpty(): boolean isFull(): Boolean enqueue(Object) throws QueueFullException: dequeue() throws QueueEmptyException: Object This is what I have done: public interface Queue { public int size(); public boolean isEmpty(); public boolean...

Avoiding diamond shapes in Java when using composition and inheritance

java,inheritance,interface,composition
I've been building a system that has five classes, with another class containing the main method to initialize, show and modify various different objects from the aforementioned five classes. I understand how to use inheritance to adopt fields in both the therapist and patient classes from the person (e.g. name,...

Is there a way to get effect of adding body to interface method?

php,interface
Java has default methods, Scala has traits. Is there a way to get the effect that given method in PHP interface has body? Assuming I have total control over the interface, the method, everything.

DialogFragment callback to Target Fragment using interface

android,android-fragments,interface,callback,android-dialogfragment
I am trying to send some data from a dialogfragment to the targeted fragment but its not working. I have written the following code, but it through exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.x.x.FragmentAlertDialog$Communicator.setI(java.lang.String)' on a null object reference Code: public class FragmentAlertDialog extends DialogFragment { Communicator callback;...

Symfony : is there a best practice about the directories' name including traits and interfaces?

php,symfony2,interface,trait
I guess I can't create a Trait or Interface directory inside my bundle since this is a keyword that would bring problems when used (i.e. use MyBundle\trait\MyTrait). Is there a best practice about how to name these directories ?...

J2SE interfaces specifications and implementations of those interfaces

java,interface,java-7
I was looking at rt.jar for some reasons and there i saw some packages like java.sql.* among others. In a typical jdbc program we write (for Connection class, for example): import java.sql.Connection; As per the docs, java.sql.Connection is interface, not concrete implementation, and java.sql.Connection is in rt.jar. When we write...

Why are Listeners in Java interfaces?

java,interface,listener
Why are all Listeners in Java interfaces? Why can't they exhibit their behavior as classes?

Java generic class that contains an instance of implementation of generic interface

java,generics,interface,architecture
I am developing an independent, self contained component, that needs domain specific parts to function properly. The part of the idea is to create a generic interface, that will settle the usage of interface's implementation in another part of this component (in my example in class B). I have written...

What is the best way to create Interfaces that are injected into constructor in C#? [closed]

c#,interface,dependency-injection,strategy-pattern
I'm working in a project where external data is fetched from different sources such as database, 3 external web apis, web config. To avoid tight coupling some interfaces are used and passed in my classes constructors, such as: public Dog(IDataAccess dataAccess, IConverter converter, IConfigAccess configAccess, ITimezoneAccess timezoneAccess) public Cat(IDataAccess dataAccess,...