interface

Proper interface use and explanation

半城伤御伤魂 提交于 2020-01-26 04:25:05
问题 I have been gasping my head around interfaces for quite a long time and I am still unable to understand their function and what do they do. I read thousands of forum posts and I keep asking myself a single question. I will explain to you what the question I am asking is. We have got this core, which does a really simple thing. We take one class, and in the main class we call the function declared in that class, by using an interface. public interface IAnimal { string GetDescription(); } class

How to make a method pop first in java fluent interface?

元气小坏坏 提交于 2020-01-25 22:02:30
问题 This is my first asking, so sorry if I messed something. I have a task to implement a Mail, using Java fluent interface. I must have fields: From, To, Subject. The problem is, I can not make "From" to appear as first and only. Example: MailBuilder builder = new MailBuilder(); builder.from("Stiliyan").to("Alexander").subject("Welcome aboard"); But when I type the first dot "." all of them appears. (eg builder.to("a").from("b")..) So in short: builder.(HERE MUST APPEAR ONLY "from").to("No

Limit generic type in subinterface in Java

喜夏-厌秋 提交于 2020-01-25 11:42:52
问题 Say I have this interface structure: public interface ItemRequestConverter<IR extends ItemRequest> { Target convert(IR request); } public interface CreateItemRequestConverter<CIR extends CreateItemRequest> extends ItemRequestConverter<ItemRequest> { } public class CreatePartRequestConverter implements CreateItemRequestConverter<CreatePartRequest> { @Override public Target convert(CreatePartRequest request) { ... } } Now I wondering whether this is possible at all. I doubt that. When I create

Limit generic type in subinterface in Java

与世无争的帅哥 提交于 2020-01-25 11:41:06
问题 Say I have this interface structure: public interface ItemRequestConverter<IR extends ItemRequest> { Target convert(IR request); } public interface CreateItemRequestConverter<CIR extends CreateItemRequest> extends ItemRequestConverter<ItemRequest> { } public class CreatePartRequestConverter implements CreateItemRequestConverter<CreatePartRequest> { @Override public Target convert(CreatePartRequest request) { ... } } Now I wondering whether this is possible at all. I doubt that. When I create

collect data in PlaceholderFragment and send it to Activity

守給你的承諾、 提交于 2020-01-25 10:20:19
问题 I'm writing a game where every player has his own tab. Every Tab is an instance from PlaceholderFragment. I thought it would be easy to implement the dynamic count of tabs and fragments but now I don't really know how to get the input data from each instance to the ParentActivity. Maybe I should mention that I want to work with java 7 (SDK version min < 24) I'm using the interface right know, but the problem is, that the user needs to press the menu item "save data" in the Activity to save

Understanding IServiceProvider and QueryService

匆匆过客 提交于 2020-01-25 09:25:27
问题 Can anyone explain the idea behind IServiceProvider and QueryService ? I don't understand what a service is and how it differs from another type of object or interface. I've seen little explanation--mainly some remarks here and here on MSDN, but I don't understand them. Why would you have IServiceProvider and QueryService instead of just having some sort of "GetAnotherObject" method? Thanks for any guidance. 来源: https://stackoverflow.com/questions/59432866/understanding-iserviceprovider-and

How to implement an interface in C++

可紊 提交于 2020-01-25 08:26:05
问题 I have an assignment and trying to understand something. I have an instruction to create two interfaces: IComparable and IPrintable . Also, I need to create a template called Interval . I am given the main function and I need to implement these classes accordingly so it will work as intended. This is the function I am currently implementing (the comments displays what the input should look like): void testDate() { Date independence(14, 5, 1948); cout << independence << endl; Date otherDate =

How do I create a BaaN interface in C#?

余生长醉 提交于 2020-01-25 00:15:26
问题 What is the best way to create an interface to the BaaN MRP system? I'm looking for a way to use C# to create an interface to update the inventory at the ERP. 回答1: You need to add a com reference to /baan/bin/bw.tlb (Ole Automation Baan Type Library) 回答2: object Baan = null ; Type t; t = Type.GetTypeFromProgID("Baan4.Application.someuser"); Baan = Activator.CreateInstance(t); object[] Parameters = new Object[1]; Parameters[0] = 3600; //Baan.Timeout = 3600; Baan.GetType().InvokeMember("Timeout

Why does angular project fail AoT build when injecting Interfaces?

江枫思渺然 提交于 2020-01-24 21:55:32
问题 Ok, sorry if the title was not clear. I'm trying to implement a pattern involving injecting interfaces. It works perfectly in JIT but not in AoT. I was hoping to get an explanation of why this doesn't work and hopefully some suggestions to make it work. Here's a simplified example of the pattern. data-manager.interface.ts @Injectable() export class DataManager implements DataManager {} export interface DataManager { getData(): Promise<Array>; ... } ^Declares Interface dashboard.service.ts

Why should I declare implemented interface methods as “public”?

…衆ロ難τιáo~ 提交于 2020-01-24 20:46:05
问题 interface Rideable { String getGait(); } public class Camel implements Rideable { int weight = 2; String getGait() { return " mph, lope"; } void go(int speed) {++speed; weight++; int walkrate = speed * weight; System.out.print(walkrate + getGait()); } public static void main(String[] args) { new Camel().go(8); } } Upon compiling the above code I've got a compilation error, related to access modifier of getGait() method. Please explain, why should I declare getGait() with public access