interface

Why would one declare a Java interface method as abstract?

China☆狼群 提交于 2019-12-27 11:39:41
问题 I used the "pull interface" refactoring feature of Eclipse today to create an interface based on an existing class. The dialog box offered to create all the new methods of the new interface as "abstract" methods. What would be the benefit of that? I thought that the fact that you were allowed to declare interface methods as abstract was a superfluous and harmless feature of the language that is not particularly encouraged. Why would Eclipse support such a style, or why would someone

How to interface Output() and Input() decorators?

扶醉桌前 提交于 2019-12-25 18:55:32
问题 I want to create an interface for components that generate JSON. I want to force each implementing component to accept a type as Input and produce an Output: import { EventEmitter, Output, Input } from '@angular/core'; import { Foo, FooConfiguration } from '../../interfaces'; interface FooConfigurator { @Output() fooWasConfigured: EventEmitter<FooConfiguration>; @Input() fooInstance: Foo; } Then, components implementing FooConfigurator would ensure the following: import { EventEmitter, Output

Java - recursive generic type definitions

梦想与她 提交于 2019-12-25 17:19:18
问题 I tried to create an interface ISortableStack using <E extends comparable <E>> but I can't move forward. What does the following do? <E extends Comparable<E>> I've tried this, but it doesn't help. 回答1: <E extends Comparable<E>> means that E must be a type that knows how to compare to itself , hence, the recursive type definition. public class Comparables { static class User implements Comparable<User> { @Override public int compareTo(User user) { return 0; } } /** * This class cannot be used

How can I convert this WordPress JSON entry into PHP array?

邮差的信 提交于 2019-12-25 17:07:45
问题 I am working on an interface to load data from a WordPress application into my own database. One table record comes with this: a:6:{i:0;s:2:"39";i:1;s:2:"88";i:2;s:2:"89";i:3;s:2:"53";i:4;s:2:"54";i:5;s:2:"91";} I know what this is representing and I think its a kind of JSON format, but I don't know how to convert this string into a readable PHP array. I´ve tried to explode() something like explode(';') , but the result doesn't make any sense. Have anyone seen this and can help me? Thanks.

Interface with generic object of the interface type [duplicate]

北城以北 提交于 2019-12-25 16:31:09
问题 This question already has answers here : Interface with List of same interface (2 answers) Closed 5 years ago . I have the following interface: public interface IObject { double x { get; } double y { get; } Holder<IObject> Holder { get; set; } } and this class public class Holder<T> where T : IObject { private List<T> items; public void AddItem(T item){ items.Add(item); item.Holder = this; } However the compiler doesn't like the AddItem method and on this line : item.Holder = this; gives me

Calling method on Document interface in Java

孤者浪人 提交于 2019-12-25 11:54:09
问题 I am trying to parse an XML file in Java and after getting the DocumentBuilder object, I call the parse method on it to get a Document object. e.g. Document dom = docbuild.parse(fileName); Then to get the root of the XML file, I use the method dom.getDocumentElement(); . Since Document is an interface as defined in the javadocs, how are we able to call a method on it without defining it first? My main objective is to create a class that inherits the Document interface, so I have to implement

Calling method on Document interface in Java

走远了吗. 提交于 2019-12-25 11:54:05
问题 I am trying to parse an XML file in Java and after getting the DocumentBuilder object, I call the parse method on it to get a Document object. e.g. Document dom = docbuild.parse(fileName); Then to get the root of the XML file, I use the method dom.getDocumentElement(); . Since Document is an interface as defined in the javadocs, how are we able to call a method on it without defining it first? My main objective is to create a class that inherits the Document interface, so I have to implement

using compareTo method when overriding compareTo?

。_饼干妹妹 提交于 2019-12-25 09:24:29
问题 when implements Comparable interface and override compareTo method, @Override public int compareTo(Name o) { int val = this.name.compareTo(o.name); if (val != 0) { return val; } if (count != o.count) { return count - o.count; } } The third line, I realized that I can use compareTo when I override it, and it automatically compares things follows the natural order. But isn't compareTo an abstract method in the comparable interface. Without defining it, it still does compare? Also, why I do not

Call to a member function get() on null for FOSuserBundle

最后都变了- 提交于 2019-12-25 09:19:55
问题 I am trying to do a redirect to the registration page, if a username does not exists in the user tables. I have done all the configurations needed and I have created the handler that looks like: namespace UserBundle\Redirection; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\RouterInterface; use Symfony

Error message 'Cannot be resolved or is not a field'

╄→гoц情女王★ 提交于 2019-12-25 08:57:02
问题 Right now I'm studying the chain of responsibility design pattern and am using Eclipse. And I'm trying to compile this code, but I have the compiling error "isLast cannot be resolved or is not a field": public class OverFive implements Discount { private Discount next; // public boolean isLast = false; public void setNext(Discount next, boolean Last) { this.next = next; this.next.isLast = Last; // Here is the error. } public double DoDiscount(Budget budget) { if (budget.getValue() > 500) {