Generics and interface

Ok let's say I have an Interface A
I have a Class B whom extends A.
In another class, I have private member :
List<A> xyz;
In a method, I receive (List<B> listabc);
I want to have in xyz a reference to all listabc items, what is the best way to do it? Cast doesn't work, so I have to iterate on abc ?
Thanks.

Change xyz to List<? extends A>

Similar Messages

  • How to define generics in interfaces

    I want to define an interface for Person, which has 2 attributes, 'Owner' and 'Access', but these attributes may be different types for different implementations of the interface. I have another interface that takes Person, so I have something like this:
    public interface Person<O, A>
        public abstract O getOwner();
        public A getAccess();
    public interface Entry
        public void addPerson(Person<?, ?> person);
    }I then have a base Entry implementation that does
    import java.util.ArrayList;
    import java.util.List;
    public abstract class BaseEntry implements Entry
        protected List<Person<?,?>>  persons;
        public void addPerson(Person<?, ?> person)
            if (persons == null)
                persons = new ArrayList<Person<?,?>>();
            persons.add(person);
    }and finally I have a concrete class that wants to use Entry and Person interfaces to do somthing like
    public class RealEntry extends BaseEntry
        private int personCount;
        public void addPerson(Person<String, String> person)
            super.addPerson(person);
            personCount++;
    }and I might have another implementation that does
    public class ListEntry extends BaseEntry
        public void addPerson(Person<String, List<String>> person)
            super.addPerson(person);
    }but the concrete implementations do not compile in Eclipse with the message
    Name clash: The method addPerson(Person<String,String>) of type RealEntry has the same erasure as addPerson(Person<?,?>) of type BaseEntry but does not override it
    I've read the generics tutorial, but it's not helped me. I'm not absolutely certain I should be using wildcards as opposed to generic method.
    Anyone know what I'm doing wrong?
    Thanks
    Antony

    Hi Stefan, I see how your example breaks things, thanks.
    My 'Entry' is a simple queue class. I compiles OK if I add the O, A to Entry and implementations, i.e.
    public interface Entry<O, A>
        public void addPerson(Person<O, A> person);
    }but it seems strange (to me) that I have to define the O, A types for the Entry interface - it makes it cluttered. I thought it should be possible to have a generic Entry interface that takes a Person objects without having to tell Entry the subtypes of classes that make up the O and A inside Person.
    I could be trying to do something impossible, but I something think it has to be possible as it seems such a common type of usage, i.e. I can have many classes that all define different types of Person implementations and can store them in Entry implementations.

  • Generics in Interfaces ?

    Hi all,
    Just a quick question about using generics in interfaces...is it possible to specify a type parameter for an abstract method, which is then made concrete in the implementing class ?
    One example is the Comparable interface...it would be nice if, instead of using the "Object" type, you could specify that the parameter type for the method should be that of the implementing class. This would get rid of the compareTo(Object o) methods which can present a run-time problem.
    Thanks,
    Michael Dodsworth.

    Hi again,
    As part of a wider question...is it possible to specify the type parameter of a class/interface (as you would in a new statement) as part of an "extends/implements..." statement:
    public class Foo
    extends Hashtable<Integer, String>{
    (the Hashtable example is from http://www-106.ibm.com/developerworks/java/library/j-djc02113.html)
    All type parameters on Hashtable are then tied to Integer and String in the extending class; all inherited methods have the signatures of that particular incarnation of Hashtable.
    Answering this, then answers the above question.
    Thanks,
    Michael Dodsworth.

  • Tutorial for make a non-generic type class from a generic type interface

    Hi there,
    How can I make a non-generic type class from a generic type interface?
    I appreciate if somebody let me know which site can help me.
    Regards
    Maurice

    I have a generic interface with this signature
    public interface IELO<K extends IMetadataKey>
    and I have implemented a class from it
    public class CmsELOImpl<K extends IMetadataKey> implements IELO<K>, Cloneable, Serializable
    then I have to pass class of an instance CmsELOImpl to AbstractJcrDAO class constructor whit below signature
    public abstract class AbstractJcrDAO<T> implements JcrDAO<T> {
    public AbstractJcrDAO( Class<T> entityClass, Session session, Jcrom jcrom ) {
              this(entityClass, session, jcrom, new String[0]);
    So I have made another class extended from AbstractJcrDAO. Below shows the code of this class and itd constructor
    public class ELODaoImpl extends AbstractJcrDAO<CmsELOImpl<IMetadataKey>> {
         public ELODaoImpl( Session session, Jcrom jcrom ) {
         super(CmsELOImpl.class , session , jcrom, MIXIN_TYPES);
    and as you see in its constructor I am calling the AbstractJcrDAO constructor by supper method
    then I got this error on the line of super method
    The constructor AbstractJcrDAO(class<CmsELOImpl>, session, Jcrom, String[]) is undefined.
    as I know java generics are implemented using type erasure. This generics are only
    in the java source file and not in the class files. The generics are only used by the compiler and
    they are erased from the class files. This is done to make generics compatible with (old) non generics java code.
    As a result the class object of AbstractJcrDAO<CmsELOImpl<IMetadataKey>>
    is AbstractJcrDAO.class. The <CmsELOImpl<IMetadataKey>> information is
    not available in the class file. As far as I understand it, I am looking a way
    to pass <CmsELOImpl<IMetadataKey>>, if it is possible at all.
    Maurice

  • Diff b/w msg mapping and interface mapping

    hi
      i have some doubt's:
       1. diff b/w msg mapping and interface mapping
       2. What is product in SLD? usually who creates the product,technical,business system??
    thx in advance..

    hI Smartsoft General User  ,
    The following r excellent websites on mapping which differentiate msg mapping and interface mapping in detail:
    Excellent PDF Document on Mapping
    http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
    Mapping Development with the ABAP Workbench
    http://help.sap.com/saphelp_nw04/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/content.htm
    ABAP Mappings
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm
    how to create a flat file out of an IDoc-XML by means of an ABAP mapping program and the J2EE File Adapter.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
    How to Use ABAP Mapping in XI 3.0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e3ead790-0201-0010-64bb-9e4d67a466b4
    These r excellent websites in SLD:
    How To…Handle the SLD for SAP XI
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9e76e511-0d01-0010-5c9d-9f768d644808
    How To…Handle Caches in SAP XI 3.0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1a69ea11-0d01-0010-fa80-b47a79301290
    http://www.sap-press.de/download/dateien/751/sap_press_exchange_infra_engl.pdf
    cheers!
    gyanaraj
    ****Pls reward points if u find this helpful

  • What is diff b/w abstarct and interface

    what is diff b/w abstarct and interface in real time where we come across, give a best real time example

    I think there have been lots of threads in this forum discussing interfaces and abstract classes.
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=389830
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5120074
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=499077
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=546668
    Interfaces define a contract for what an implementing class should provide. Abstract classes do the same but they can also provide some common part of the implementation.

  • Names of interface tables and interface programs of oracle modules

    Hi all,
    i need urgent and accurate information about the names of interface tables and interface programs of the following oracle modules,R12, or either ther are custom made. Any accurate link refering to the desire information would be much appreciated.
    Plus i need a clear and simple definition and purpose of interface tables and interface program and by what other names are they known in industry.
    Data Object,Oracle Module
    Chart of Accounts,Oracle General Ledger
    Trial Balance,Oracle General Ledger
    Supplier Master,Oracle Payables
    Open Supplier Invoices,Oracle Payables
    Open Supplier Credit/ Debit Memos,Oracle Payables
    Open Supplier Advances,Oracle Payables
    Bank Master,Oracle Cash Management
    Customer Master,Oracle Receivable
    Asset Categories,Oracle Assets
    Asset Master,Oracle Assets
    Item Master,Oracle Inventory
    Item Categories,Oracle Inventory
    Sub Inventory and Locators,Oracle Inventory
    Item On Hand Balances,Oracle Inventory
    Item wise Per unit Cost,Oracle Inventory
    Bill of Material,Oracle Discrete Manufacturing
    Departments,Oracle Discrete Manufacturing
    Operations,Oracle Discrete Manufacturing
    Routings,Oracle Discrete Manufacturing
    Resources,Oracle Discrete Manufacturing
    Overheads,Oracle Discrete Manufacturing
    Employee Master,Approval Hierarchy
    Approval Hierarchy,Approval Hierarchy
    Open Customer Invoices,Oracle Receivables
    Open Customer Credit/ Debit Memos,Oracle Receivables
    Open Customer Advances,Oracle Receivables
    Pending Requisitions,Oracle Purchasing
    Pending Purchase Orders,Oracle Purchasing
    Open Sales Orders,Oracle Order Management
    Price List,Oracle Order Management

    Hi;
    Its metalink note you need to login metalink wiht valid CSI(customer Support Identifier) number to can se note via using note number.
    Please see:
    Oracle EBS Based and Interface tables
    Oracle EBS Based and Interface tables
    Regard
    Helios

  • Receiver Determination and Interface Determination Condition conflict in ICO

    Hi,
    I found a strange issue today while configuring two receivers using the Receiver and Interface Determination conditions.
    Sender - Proxy Service
    Receiver1 - ReceiverA
    Receiver2 - ReceiverB
    Receiver Determination Condition : When Field1 = 100, message should flow to ReceiverA and ReceiverB
    Interface Determination Condition (ReceiverA) : When Field1=100 and Field2=50 message should flow to a specific interface in ReceiverA
    There is no Interface Determination condition for ReceiverB, for all messages having Field1=100, it should go to ReceiverB.
    Test Scenarios:
    1) Field1=100, Field2=50 : Message flows successfully to ReceiverA and ReceiverB
    2) Field1=100, Field2=89 : Message fails to process from ECC itself throwing Interface Determination not found error. Ideally this is a positive scenario for ReceiverB and it should send the message to ReceiverB without any errors. But, this did not happen in this case
    I tried the same by configuring the conditions completely in Receiver Determination itself without using the Interface Determination, it worked perfectly fine. But, just wanted to understand that if this is an expected behavior.

    Hi Sherin,
    As there are two receivers Receiver A and Receiver B.You need to create two bussiness components and two communcication channels for two receivers and one Reciver Determination, two Interface Determination,two Receiver Agreement.In Receiver Determination you need to keep the below and condition.
    In the above screenshot the two receiver are Receiver B and Receiver C and Field 1 is Key_Value and Field2 is Emp_ID.
    If the Key_Value=100 and Emp_ID =22 then the message should go to both the receivers B & C by keeping the following AND condition
    If the Key_Value=100 and Emp_ID is not equal to 22 then the message should go only to Receiver B by keeping the following condition
    You need not keep any condition in Interface Determination just create 2 Interface determination for two receivers.
    Hope this helps you.
    Thanks,
    Durga.

  • I have installed succesfully a PCI cards seen by windows but it does not appears in the device and interfaces tools of the Measurement and automation manager?

    Cannot install new objects in device and interface to use the ni-imaq library and to take image from my camera.

    Which PCI card did you install? The PCI-8252 and PXI-8252 will not appear in MAX. Does your card appear in the Windows Device Manager?

  • Compiling Nested Classes and Interfaces

    I am looking for documentation about compiling nested classes and interfaces. I have found something in the JVM Specification, but there does not explain how a nested class is compiled and what is included in the top level class to mark a "place holder" to the nested class. The JVM Specification in this topic cite the web page http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html that does not exists any more.
    My root problem is that: I am compiling a class with a private nested class, but in the class file generated TopLevelClass$NestedClass.class the class does not have the private modifier. So I am not understanding why the "private" modifier was removed during compilation.
    I performed the same test with a protected nested class and the result was the nested class with the public modifier. So I am not understanding why the "protected" modifier was changed to "public".
    Thanks in advance,
    Mardoqueu.

    This should not be happening. What compiler are you using? If it's a reasonably recent Sun compiler, could you post a minimal example?

  • I want to edit properties of the interface windows opened while "Open File", "Save Page As" and interface opened during Downloading of any file.

    I am doing a small project on dedicated web client where in user automatically logs in non-root user and Firefox automatically starts.
    I am using Fedora 14 kernel 2.6.35.12-88.fc14.i686 and Firefox 3.6.16.
    I have installed only Gnome in my computer with no Nautilus or other file browser on it.
    I want to edit properties of the interface windows opened while "Open File", "Save Page As" and interface opened during Downloading of any file.
    Please guide me for this.

    First, I sent an email to the author of PhotoME to inform him of the serious issues his addon caused with Firefox latest versions.
    Now, for those of you who do not have the PhotoME addon and yet experience the same problem that I had and that I described above, I suggest the following strategy.
    As PhotoME did cause these problems with Firefox latest versions, I am pretty covinved other addons probably might cause these problems too. Therefore, adopt the following method.
    Test one addon at a time to see if this particular addon is behind your Firefox issues like the ones I had.
    So, disable one addon only at a time. Then close your Firefox and restart it from scratch and see if you still have your Firefox problems. You must restart the Firefox browser from scratch. If you still have these Firefox problems, re-enable the disabled addon, restart your Firefox (again!) and repeat the same method for every single addon that you have.
    Try to be selective by choosing first addons that are more likely to cause your Firefox problems such as not very well-known or not very popular addons (like it was the case for the PhotoME addon).
    If this method works or if it does not work, report it on this web page so that others can be helped with your comments.
    I hope this method will help you because I was really upset that I had these Firefox problems and I first thought it was the fault of Firefox, only to discover later that this PhotoME addon was the culprit and had caused me such upset.

  • Generic and Inheritance, how to use them together?

    Hi guys, I am trynig to design some components, and they will use both Generics and Inheritance.
    Basically I have a class
    public class GModel <C>{
        protected C data;
        public C getData(){return data;}
    }//And its subclass
    public class ABCModel <C> extends GModel{
    }//On my guess, when I do
    ABCModel abcModel = new ABCModel<MyObject>();The data attribute should be from MyObject type, is it right?
    So, usign the netbeans when I do
    MyObject obj = abcModel.getData();I should not use any casting, since the generics would tell that return object from getDta would be the MyObject.
    Is this right? If yes; did someone try to do that on netbeans?
    Thanks and Regards

    public class GModel <C>{
    public class ABCModel <C> extends GModel{public class ABCModel <C> extends GModel<C>{
    ABCModel abcModel = new ABCModel<MyObject>();ABCModel<MyObject> abcModel = new ABCModel<MyObject>();

  • Extended Receiver Determinatipon and Interface Determination?

    Hi,
    Where exactly (In which business cases) we can implement or required Extended Receiver Determination and Interface Determination?
    Thanks,
    Naidu.

    Hi,
    There are only two modes standard and Extended, Enhanced receiver determinatrion is Extended receiver determination only.
    Enhanced(Extended) receiver determination  -->
    Whenever list of receivers is determined dynamically at runtime, using a message mapping then it is called enhanced.
    Enhanced Interface Determination--> It is when you want the target interfaces to be defined dynamically based on the multimapping, that is called enhanced interface determination.
    Refre SAP help for more detail
    http://help.sap.com/saphelp_nw04s/helpdata/en/42/ed364cf8593eebe10000000a1553f7/frameset.htm
    Thanks!
    Edited by: Sudhir Tiwari on Dec 5, 2008 6:34 AM

  • Receiver Determination and Interface Determination

    Hi,
    Please, can anyone explain what is the concept of 'Receiver determination' and 'Interface Determination'?
    Thanks,
    Harikumar. S

    Hi,
    >>>>Receiver determination
    its about finding the receiver system for particular source system and outbound interface.
    Suppose,you want to send data from file->XI->SAP and CRM based on some condition
    in this scenario you need to determine whether to send file data to SAP or CRM system,this decision you will do in Receiver determination
    in Receiver determination screen you need to provide the following details
    1.Source system(ex: File system)
    2.Outbound Interface(File Message Interface)
    3.condition and receiving system(ex:if some x field value in source payload is 1 go to SAP elseif '0' go to CRM system)
    >>>>>>Interface Determination
    suppose in above scenario you determined the receiver i.e SAP,you will have number of IDOCs (Inbound Interfaces)in SAP.
    so to which IDOC you will send file data?This decision you will make in Interface determination(we can it as Inbound Interface determination).if you find the IDOC is CREMAS then how will transfer file structure data to IDOC structure? answer is Message Mapping
    From all the above decisions you need to provide following details in Interface determination screen
    1.Source System
    2.Outbound Interface
    3.Receiver System
    4.Inbound Interface(IDOC type)
    5.Message Mapping(i.e file to IDOC)
    Even in Interface determination you can specify the condition to select Inbound Interfaces(ex.IDOCs)
    if you have any doubts please lets know.
    Cheers,
    Jag

  • No Devices and Interface in MAX

    Hi all,
    I recently installed the evaluation version of LabVIEW and I am trying to communicate with a Mark-10 Series 5 force gauge. The problem, however, is that MAX does not seem to detect the instrument or any other instrument. There isn't even a Device and Interface tree.
    I am running Windows 7 and the Mark-10 drivers are installed (and is detected by the device manager as a USB device).
    Anyone have any idea what could be wrong?
    Solved!
    Go to Solution.

    I recently went through this problem. You have to register a USB instrument to use the VISA driver. There is an NI tutuorial on how to do this. You can find the tutorial here.
    This allows 3rd party instruments to show in MAX and be used in LabVIEW.
    Rob

Maybe you are looking for

  • Creation of background job from SE38

    hello all... In the selection screen of my report program, there are two radiobuttons - read mode or update mode. In read mode, the program reads an excel file and gives the output in teh form of errors, if at all, after some chekcs on this excel fil

  • Spry Tabbed Panels position customization

    The default position for Spry Tabbled content panels is to render below each tab when each tab is clicked. However I would like the content panels to render above the tabs, so that the tabs are positioned below the content panels. I cannot figure out

  • Corrupt data error when using Windows backup on Oracle

    Our SAP servers include a SDLT internal tape drive that we use for doing a complete system backup.  When using Windows Backup we get the following message in the backup log: WARNING: Portions of "\oracle\T00\sapdata1\protd_2\PROTD.DATA2" cannot be re

  • Rss feed images missing or wrong

    Anybody seen this sort of problem before and know what to do about it?

  • PCAlert4 error

    I am running the MS-7104 motherboard with bios 6.00 PG. The system is running windows 2003. When I install PCAlert 4 on the system I get the error "Failed to load Hardware Monitor Driver" Is PCAlert compatible with 2003? Thanks, John