Eliminating type parameters used only for superclass information?

I have a class called BaseObject. I have another class called Reference. A
BaseObject has one canonical Reference that can be gotten and set. A Reference
is capable of pointing at a BaseObject subclass of a particular type and can
return the Class of that BaseObject subclass.
I'd like to genericize these classes so that if you create a reference and
assign it to an object, their types should line up. That is, a Reference that
points to a Banana should not be able to be assigned as a canonical reference to
a Cherry.
My goal is to express these type constraints once somewhere. I cannot seem to
achieve my goal.
Pass one, which looks OK at the outset:
  public class BaseObject<T extends BaseObject> {
    public Reference<T> getReference() {
    public void setReference(final Reference<T> reference) {
  public class Reference<T extends BaseObject> {
    public Class<T> getObjectType() {
  }But that would mean that every subclass of BaseObject<T> would need to be
declared with a type parameter as well to permit further subclassing, right?
Like so:
  public class Fruit<T extends Fruit> extends BaseObject<T> {
    // Note: T is not used in this class except to "pass it up" to BaseObject
  public class Banana<T extends Banana> extends Fruit<T> {
    // Note: T is not used in this class except to "pass it up" to Fruit
    // Callers will have to say: new Banana<Banana>();
  }That seems WEIRD to me. Is there any way to...to...hide the genericization of
the fundamental classes--BaseObject and Reference--without forcing the type
parameters to be propagated all the way down the subclass stack?
In other words, assuming a hierarchy of Object<--Fruit<--Banana, is there any
way to have Fruit and Banana not mention type parameters at all?
Thanks,
Laird

I'm up a creek here, aren't I?I think so. It's been a while since I complained
about the lack of 'self-types' in Java. 'Self-type'
actually means something different in other languages
(Scala for example) so just be aware of that.AH! Yes! That's exactly what I'm talking about. OK, knowing that I'm screwed helps a lot, actually. It lets me know where I can and cannot apply generics to solve problems.
I would envision:
class BaseObject<self>
// OR
class BaseObject<T extends self>The idea would be that self is what ever the
'current' class is. So if you used the first one,
the type of the class that extended BaseObject would
be assumed to be the parameteric type. The second
one would require that the parameter (if present at
time of variable of declaration is instantiation) be
at least as specific as the current extenstion of
BaseObject.Yes, exactly. This would be wildly helpful. Oh well.
Back to 1.4 syntax.
Cheers,
Laird

Similar Messages

  • Numbering Group G1 can be used only for one CoCd and cash journal number

    Hello,
    I was trying to create a cash journal when I got the error message:
    "Numbering Group G1 can be used only for one CoCd and cash journal number".
    Does anyone have an idea what could be wrong?
    Thank you,
    Bola

    Hi,
    Please check whether more than one number range is maintained in  transaction code FBCJC1. If yes, please keep only one as Cash Journal has only one number range. This is the internal number range for Cash Journal.
    If you want different number range for accounting documents then create new document types and assign number ranges to it.
    Regards,
    Tejas

  • Using numbers for roster information. Imported from another program. Now seem to have extra headers, one listing name, address, etc.

    Using numbers for roster information. Imported from another program. Now seem to have extra headers, one listing name, address, etc. & another A, B, C. They don't mesh & can't get rid of either. All info there, but can't change width of columns.

    I think my problem is that I have inadvertently created three tables (I only want one). I have included a screen shot of the light grey line under B and the words Table 1 behind it.

  • Is xmlgen.insertxml used only for single table

    Is xmlgen.insertxml used only for single table or can be used to insert the xmldata into xle tables
    Thanks,
    Sudheer

    Hi Sudeesh,
    I am fetching data for PO details, GR details along with condition types of PO.
    All data is collected in ALV OUTPUT itab, after this I am trying to assign the values of VAT from another itab in ALV OUTPUT LOOP using READ TABLE with reference to PO-PO_ITEM-CONDITION_TYPE.
    Now, when the alv loop is getting executed and in that I am fetching data for VAT using READ statement, the program is assigning VAT to all records of output alv with comparison of PO-PO_ITEM-CONDITION_TYPE.
    see:
    LOOP AT it_alv ASSIGNING <fs-alv>.
         READ TABLE it_vat ASSIGNING <fs-vat>
              WITH KEY ebeln = <fs-alv>-ebeln
                               posnr = <fs-alv>-posnr
                                kschl = 'JVCS'.
         IF sy-subrc = 0.
              <fs-alv>-vat = <fs-vat>-kbetr / 10.
      <fs-alv>-vat_val = <<fs-alv>-vat * it_alv-menge.
         END IF.
    END LOOP.
    Please refer above.
    Thanks.
    Ritesh

  • Error while deleting Cash Journal (Numbering group 1001 can be used only for one CoCd and cash journal number)

    Hi,
        While i am try to delete Cash Journal system throws me error (Message No.:FCJ065: Numbering group 1001 can be used only for one Co. Code  and Cash Journal). Kindly provide me solution on that.
    Regards,
    Tarak

    Hi Tarak,
    You can use the config nodes in SPRO to set up number ranges for your cash journal documents.
    IMG Path> FI Global Settings>Bank Accounting>Business transactions>Cash Journal
    Define Number Range Intervals for cash Journal documents
    Define Numbering Groups
    Define Number Ranges for numbering groups
    After defining the number group here, you assign that in "Set up Cash Journal" Check if there is any clash anywhere in your configuration for different cash Journals.
    Regards,
    Kavita

  • AFAB IM document type is defined only for batch input

    Hello Everybody,
    With the new version ECC6, I have this message error : "document type is defined only for batch input"  when I launch the monthly depreciation with AFAB transaction.
    Thanks a lot in advance for your help !
    Regards.

    Hi
    For this document type in OBA7, remove the check for 'batch input only'
    Thank You,

  • LSMW used only for master data upload?

    Hi
    Can you please let me know if LSMW is used only for master data upload or we can also use it for transaction data ?

    Hi Christino.
    I have come across a standard SDN thread which deals with the uploading master data, refer it:
    [SDN Reference for uploading master data using LSMW|how can we upload master data by using LSMW;
    [SDN reference for which uploading is preferred (Master data or Transaction data)|Which one is better for uploading data LSMW or ECATT ?;
    Good Luck & Regards.
    HARSH

  • The external GPS is used only for 911 but the device will not op without it...this causes great inconvenience for me, having to run that cable to a window in the trwo houses I use it..ids there a way to disable the GPS if I do not care about the 911 funct

    the external GPS is used only for 911 but the device will not operate without it...this causes great inconvenience for me, having to run that cable to a window in the two houses I use it..is there a way to disable the GPS if I do not care about the 911 functionability..?  this is the only downside I have with the network extender and it renders my device useless..

    Nope, GPS is a Federal requirement for anything operating a cellular telephone signal.  You don't ever plan to call 911 until you are in an emergency.  I don't see that requirement changing any time soon.
    If you are truly inconvenienced by the VZW network extender then perhaps you should disable you calling features in these areas and swap over to WiFi only.  There are many services and apps out there that can route your phone services through internet service providers. 

  • I want to set default printer settings to be used only for a specific type of application, certain documents. All other print jobs should use a different default setting for the printer.

    I am printing a specific document from a web based application. This document need to be printed in landscape. So I would like to set the default settings for this specific printer to landscape. But for all other printers it should be portrait. But this does not seem to work. The browser picks the settings from the standard/default printer and uses this for all print jobs.

    Embie wrote:
    I was told by support that my problem was a hardware problem and that HP would not replace the faulty hardware.  Great.  I will replace my faulty hardware manufacturer.  Simple, HP never again.
    In the hour since you have registered you have posted seven messages, none of which contain any useful information that would allow someone here to help you.  Please read this post then provide some details in a new thread.  What printer model? What operating system? How is the printer connected - USB, wired LAN, Wireless LAN, bluetooth?  What is the problem you are having (with the printer...)?
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Obtaining Generics type parameters using reflection

    I have been trying to obtain the type parameters of a method using reflection. This is what I have done:
    getGenericTypeParameters(aMethod.getTypeParameters());
    private static String getGenericTypeParameters(TypeVariable genericParameters[])
           String returnName = new String();
                   if(genericParameters.length > 0)
                           returnName += "< ";
                           for(int i=0; i<genericParameters.length; i++)
                                   if(i > 0) returnName += ", ";
                                   returnName += genericParameters.getName();
    returnName += " >";
    return returnName;
    } This doesn't take care of the cases when the method is of the form  public static <T, V extends T> boolean isIn(T x, V[] y)
    and the type parameters I get using the method I've written is <T, V>
    Is there any workaround or a better way of doing it?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Have you consulted Angelika Langer's [Java Generics FAQs|http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html]?

  • Modifying Existing Partitions on HDDs to be used ONLY for Mass Storage.

    I've included an image of my Disk Configs.  I want to use Disk 1 and Disk 2 ONLY for mass storage.  Therefore, I would like to have as few partitions and virtual drives (volumes) as possible.  Currently I can only change the name of the
    first named (lettered) drive/volume on each HDD. (Note: Drive 1 will contain  one or more System Images generated by Windows 8.1 Recovery).  How do I make each drive more or less partitionless and named by only one letter? Further, since Drive 1
    will be used to store system images, does it need any special partitioning assuming some day I may want to recover the system from that drive?  Thanks.

    I have used DISKPART to restructure the two disks in question but the question remains about specific partitioning, if any, that might be needed on Disk 1, which is to house only System Images generated from Windows 8 Recovery.

  • How to use only for scanning without installing printer cartridge

    I have an old all in one and want to use it only for scanning without installing printer cartridge. I get the red signal of no i9nk and "E" msg in copy no button. If I give scanning request from HP solutions centre I get an error message " An error occured while communicating with thescanning device"

    Hello , Welcome to the HP Community! I understand that you are trying to scan on your HP Deskjet F380 All-in-One Printer without having cartridges installed. I'd like to shed a little light on this for you. Some HP printers are able to scan without ink installed, but most do not. If the cartridge lights on the product are blinking and there is an "E" in the copies window, then the printer is in an error state and will not function until cartridges are installed. If the printer is in an error state, that would describe the message you are getting that "An error occured while communicating with the scanning device", as the printer would not respond when prompted by the software. You can check the blinking light combination on the printer and follow the steps in this document to resolve the error state and continue using the device.Blinking Lights on the HP Deskjet F300 All-in-One Printer Series Hope this helps!Thanks so much for posting.

  • AppleScript how to use "get" for field information and drop-down boxes?

    Hi all,
    First post.
    Looking to use the "get" function or similar for getting information in a list or from a drop-down box or a field.
    Example, you open keychain, open the info. for a cert and want to read the currently selected trust setting for "When using this certificate" drop-down.
    Or, you want to check the Common Name field under details.
    How would I return these specific values?
    Thank you,
    -b

    The exact question being asked here: http://forum.soft32.com/mac/select-table-row-ftopict101735.html
    But, that doesn't work with the latest AppleScript.

  • I want to change my name on my outgoing ID. I want to use my professional name rather than the name i use only for legal purposes as that is how people know me

    my friends and clients know me as Jeanette Vonier
    this is also on all my bank accounts
    I use my birth name Jeanette Stringham only for legal documents and credit cards.
    I prefer to have my professional name Jeanette Vonier show as my id on messages.
    however the thunderbird mail through gandhi.net inserted the professional id instead and I cannot figure out how to change that. as a consequence my emails may be flagged as spam or go unopened.
    please advise how I may correct that and change the name showing up.

    The way to change what ever people see when they get your email is to set up your email the way you want to. '''Modzilla''' defaults to the name that you use for your computer.
    '''Open Modzilla''' go to tools then '''account settings''' When that page opens you will see your name as it appears on your email and your email address you can change any of this if you want and even create a signature which can be really cool if you know some basic HTML

  • Airport Express used to be base station, now want to use only for AirTunes

    After I moved to to different neighborhood, ATT informed me I had to upgrade from my former "elite" DSL to UVerse, which has wireless router.  Want to use my Airport Express for AirTunes in a different part of the house, but I have repeatedly screwed up my network trying to reconfigure AE.  Anybody have experience with this?  Help!!

    Thanks, Bob, for your quick response. Bit of a long story - I am talking about my place in the city where I live to work, about 6 hours away from where I am now; I am heading back there shortly.  But, here's something like the whole story (as much as I can recall without the scratchy notes I have down there):
    When I moved from apartment to house I bought 2 weeks ago, everything seemed fine - Uverse was installed and I used the AE to run powered speakers while I moved in.  But then I noticed that my iPhone, and my friends' smart phones, would not connect to my home network.  It was after I spoke to ATT support the first time, and they had me change security from WAN to WEP that my Airport problems started.  My messing around trying to figure it out crashed my network at least once and caused another hour-long session with very helpful ATT support person re-setting my network.
    So, Uverse security is WEP.  My newish MacBook Pro runs 10.7.4.  I was very frustrated by Airport Utility 6.1 not showing the AE, or only doing so if I made it my "base".  I see from my older iMac here at home that I possibly need an older Airport Utility to detect the AE.  But beyond that, I am gun-shy to try anything else with the AE without some advice.

Maybe you are looking for

  • B1 Validation Conf. to change rows of a SO

        Hello - I would like to be able to change all rows in a sales order.  We have a custom field added to the sales order as a column.  It's a combo box called shipping instructions with three values.  If we have an order with twenty lines and wish t

  • Where is the photo for a card stored?

    Good Evening: Does anyone know where the pictures used for contacts in Address Book are stored? Once a picture is added to a contact, is that image added to a file somewhere or is it referenced from another location? I am trying to find an original t

  • X4100 LOM problems out of the box

    Straight out of the box I am having trouble connecting to lom. Using a serial cable I can connect and see the lom service start after power is connected, when the login line appears i loose control of the session. Any ideas? I don't know what the IP

  • Inserting xml in sqlplus with semi colon at end of line

    Hi I'm trying to insert some generated XML. There are carriage returns in the XML and some lines have a semi colon at the end. The SQLPLUS interface is taking the semi colon as the instruction to execute. Can I mask the semi colon so it's not interpr

  • Can't read my kids' texts online - I get it - but when did this rule change?

    I clearly remember having a discussion with the Verizon rep about text messaging when we set up our account. He was really trying hard to sell us on the parental controls package which among other things, would allow us to monitor content. From what