Unchecked conversion warning - What is the proper way to fix this?

I've been trying to figure this out for awhile now, and I have not seen an example that will set me on the right track. Given the following code:
        public TreeSet<String> sort = new TreeSet<String>(CI_NE_Comparator);
        public static Comparator CI_NE_Comparator = new CaseInsensitiveNeverEqualsComparator();
        public static class CaseInsensitiveNeverEqualsComparator implements Comparator
          public int compare(Object o1, Object o2)
               String s1 = (String) o1;
               String s2 = (String) o2;
               int compare = s1.trim().toLowerCase().compareTo(s2.trim().toLowerCase());
               if (compare == 0)
                    return 1; // ensure like values are never deemed equal
               return compare;
     }I'm getting a warning declaring the class variable sort:
Type safety: The expression of type Comparator needs unchecked conversion to conform to Comparator <? super String>
So just what is the proper method to make the Comparator conform to generics?
** Btw - if anyone knows of a better way to do that comparator, I'm all ears!

Why don't you want like values to be deemed equal?
What would be wrong with using
String.CASE_INSENSITIVE_ORDER?The code you see above is a stripped down example. We have the need to present data records in alphabetical order to a user, and sometimes these records have the same dscr, but that doesn't necessarily mean it's a unique record. Because of the backing query, I can't rely on the order in which the records were received.
I can't modify the queries. Also, I can't modify the 30 or so different types of data records, all having the common field dscr, so that I can write a better implementation. But, I can write a better comparator.
This is all legacy code that I've been working with, so I have to make sure things work as they did before.

Similar Messages

  • I have Boot Camp running on a separate HD (not a partition on my Mac drive).  I would like to partition the PC HD to have a multi boot PC.  What is the proper way to do this and how do I select which partition to start the PC?

    I have Boot Camp running on a separate HD (not a partition on my Mac drive).  I would like to partition the PC HD to have a multi boot PC.  What is the proper way to do this? How do I select which partition to start the PC?

    I have Boot Camp running on a separate HD (not a partition on my Mac drive).  I would like to partition the PC HD to have a multi boot PC.  What is the proper way to do this? How do I select which partition to start the PC?

  • I have been filling up my internal memory on my laptop after years of video editing. I now want to export all this footage to an external hard drive. What is the proper way to do this.

    I have been filling up my internal memory on my laptop after years of video editing. I now want to export all this footage to an external hard drive. What is the proper way to do this.

    Are the videos being stored in iMovie or another application? Have you exported/shared the video? If the video is in iMovie what version of iMovie are you using? Give as much info as possible, and you may also want to post the question in the iLife section of this forum since more people with video skills will be reading the iLife/iMovie threads.

  • I'm running Windows XP and FF 8.0. I'm having more trouble than ever with intermittent streaming and videos not playing all the way through. What is the easiest way to fix this?

    . I'm running Windows XP and FF 8.0. I'm having more trouble than ever with intermittent streaming and videos not playing all the way through. What is the easiest way to fix this?

    That may be a problem with the VLC plugin. VLC has never worked for me properly on the occasions that I've tried it on Windows and Linux, so I have stop using it. There are usually other plugins or media players available that work better.
    What kind of media files are that?
    For WMP files you can install the new Windows Media Player plugin you can also try RealPlayer and QuickTime if it is about media that those programs can handle to see if that works better.
    * https://support.mozilla.com/kb/Using+the+Windows+Media+Player+plugin+with+Firefox
    * http://kb.mozillazine.org/Windows_Media_Player#Missing_plugin
    * http://www.interoperabilitybridges.com/windows-media-player-firefox-plugin-download

  • I have iphone 5, after upgrading it to iOS7, front is working find unfortunately rear camera became blurred, what is the best way to fix this? Looking forward to the best solution of this problem.

    I have iphone 5, after upgrading it to iOS7, front is working find unfortunately rear camera became blurred, what is the best way to fix this? Looking forward to the best solution of this problem.

    WORKAROUND FOUND ! Download and install "Awesome Camera" app and take a picture with that app. After 1-2 seconds of standby, it will work. Then you can go back to default Camera app which would work again.Please let me know

  • I bought a Macbook Pro second hand and their is a line on the screen, what is the best way to fix this?

    I bought a macbook pro from a cash converters store. It was online and in the description didn't mention anything about this issue. I can't really explain it very well so here is a picture.
    http://i839.photobucket.com/albums/zz318/donnam1993/photo-2.jpg
    Is there any way to fix this, if at all? I don't really know very much about macbooks and since i just got this yesterday i have no idea what caused this. Thank you very much for your help.

    It's difficult to determine if your photograph shows a smudge on the exterior of the display, or if it is a display anomaly. Turn up the brightness. If the image changes it's a display problem.
    You can clean the first one, but if it's the latter it is a hardware defect that will require parts, tools, labor or money to fix.

  • What's the proper way to update this table field?

    I've got a table with a field of TOTAL.  There's a linked table with a field of AMOUNT.  There's one main table record to multiple linked records.   I'd like to replace the TOTAL with the sum of Amount for each link.   I'm
    having a hard time setting up an update query to do that.  Any suggestions?
    ajw

    The proper way is almost certainly not to store the totals in a column in a table at all, but to compute them in an aggregating query, e.g. to return the sum of transaction amounts per customer:
    SELECT CustomerID, SUM(Amount) AS TotalAmount
    FROM Transactions
    GROUP BY CustomerID;
    Storing aggregated values is only necessary if these can legitimately be amended independently of the values from which they are computed.  This is not out of the question, but is rarely the case.
    Ken Sheridan, Stafford, England

  • What is the proper way to slice this?

    I'm newbie, have taken a DW class, but only info I have about FW is self-taught from the various tutorials
    by John Wylie, Matt Stow, etc.  on the adobe website.  Created my first webpage comp
    in FW (attached) and trying to bring it to DW, but having a lot of trouble trying to figure out how to properly
    slice the banner portion so that I don't lose the page gradient, and I am able to  use FW to generate the "up" and "down"
    state of the navigation buttons (hover will be coded in DW).
    Is there a proper, not too complex method of slicing this so that I can bring it to DW?  Or have a created an impossible
    design by putting navigation areas along the same y-co ordinate as the logo?
    This forum has been fabulous!  Thanks to all that have helped me!

    Thanks for answering, can you clarify a little further, Please?
    I was using the overall page gradient as the bckground image.
    1. Can I have 2 bg images
    on one page, the gradient and the banner area?  (The gradient starts in the upper left hand corner of the page)
    2. Do I Export as Images only? or as  CSS and images?
    3. When you say "right align and add to header, you are telling me to add it as a layer to the jpeg header file,
    then flatten/optimize the image to import into DW?
    4. For the buttons you say I can add a div inside the header to hold the navigation.  This is what
    I wanted to do, but Where to slice?  If I slice only the navigation buttons, (either all together or
    individually, how to I set up the div in DW so as not to have the buttons overlay?
    5. I don't understand what you mean by "turn off the large slice view"
    thanks

  • What's the proper way to do this cross-platform app?

    hey y'all
    I'm making a multimedia app  with LV2010 and I'm trying to make it cross platform (win and mac os x).
    The functionality I need requires the use of  system libraries, I have access to somewhat similar functions in both OS's
    (winmm.dll in windows, coreMidi.framework in mac OS X)
    Except for the  actual system calls  the VIs will be identical.
    I can make the VI work in either platform by using the  call library function node,  but  i don't want to  have two copies of everything.
    I've tried  doing  a  wrapper sub  VI that puts  the  call library function node  in a case statement  and detect the OS but this VI will not be  executable because of dependencies (won't find the  library referenced in one of the cases. depending on the OS executed)
    Is there any way  I can specify  which subVI's to load  on a project or something to  get this whole dependency issue sorted?
    Solved!
    Go to Solution.

    You want to wrap the platform-specific code in a Conditional Disable structure, with one condition for each supported platform.  The OS symbol is already defined; see the help for Creating Conditional Disable Structures, which lists the pre-defined symbols and values.

  • What is the proper way to fix the Flash Plug-in issue that causes Firefox to hang when playing Flash videos

    This is annoying and causing me to set my default to Chrome. Firefox hangs when playing Flash. I have tirelessly tried everything I could. Uninstalling Flash via the Adobe download. Uninstalling FF and every single one of it's folders. I've done it all, multiple times....and continue to have the exact same problem, any Flash video hangs. Please help, I have read countless articles about others having this same problem, yet nobody offers a real solution.
    == URL of affected sites ==
    http://www.youtube.com

    This is annoying and causing me to set my default to Chrome. Firefox hangs when playing Flash. I have tirelessly tried everything I could. Uninstalling Flash via the Adobe download. Uninstalling FF and every single one of it's folders. I've done it all, multiple times....and continue to have the exact same problem, any Flash video hangs. Please help, I have read countless articles about others having this same problem, yet nobody offers a real solution.
    == URL of affected sites ==
    http://www.youtube.com

  • What is the proper way to change a url link?

    I need to tell DW to change all url links (on all pages) going to an old url to a new url. What is the proper way to do this? thanks.

    Did you even read my reply properly?
    'Defining a site' in DW has everything to do leveraging most functionality with FUNDAMENTALS of DW usage.
    'Change links sitewide' is an option within DW that will change links across sites by replacing an old link with a new - for DW to do this for more than just ONE FILE in your site, DW has to know what other files make up your site. This is why 'Defining a site' is critical.
    If you do feel otherwise, please go ahead and wait for somebody else (an expert) to post his views on this. Let's see what they have to say.
    Either which way, I really think you should change your attitude while posting on this forum. That will not only help you, but all of us here.
    Good luck.

  • What is the proper way to change rowHeight? (possibly animate?)

    What is the proper way to change rowHeight for UITableView? I set tableView.rowHeight and do a [tableView reloadData]. Is this necessary? Also, is it possible to animate the height change? It is not a standard transition.

    Not a perfect solution for your animation question - but....
    in the function where you want to change the height
    WARNING PSUDO CODE
    //indexPath is the path for theCell you want to edit
    thePlaceThatYouStoreYourHeights[x] = aNewHeight;
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
    and inside of - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath (NSIndexPath *)indexPath
    return thePlaceThatYouStoreYourHeights[indexPath.row];
    Basic flow
    1. Store new desired height somewhere
    2. Remove the cell deleteRowsAtIndexPaths
    3. UITableView paints the animation for the "remove" transition **see note
    4. Re-add the cell insertRowsAtIndexPaths (which subsequently kicks of a call to heightForRowAtIndexPath before animating)
    5. UITableView paints the animation for the "add" transition
    You do NOT need to call reloadData to get this to work.
    **note: an enum such as UITableViewRowAnimationNone does not exist (it should but it doesnt seem to). the docs for InsertRowsAtIndexPaths say "A constant that either specifies the kind of animation to perform when inserting the cell or requests no animation." however there are only 5 items in the UITableViewRowAnimation enum and UITableViewRowAnimationFade resolves to 0 - so passing NO will actually get you fade. Nor will it take nil.
    Hope this helps shed some light.

  • How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes?

    How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes? I wanted my teenager's AppleID to be different from mine so that she couldn't charge stuff to my AppleID, therefore I created me another one. Now when I go to Sync either device, it tells me that this IOS device can only be synced with one AppleID. Then I get a message to erase it, not going to do that, lol. If I logout as one ID and login as the other, will it still retain all synced information on the PC from the first IOS device? If I can just log in out of the AppleID, then I have no problem doing that as long as the synced apps, music, etc stays there for both. I am not trying to copy from one to the other, just want to make sure I have a backup for the UhOh times. If logging in and out on the same PC of multiple AppleIDs is acceptible then I need to be able to authorize the PC for both devices. Thanks for the help. I am new to the iOS world.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • What is the proper way to record line numbers in Master/Detail records?

    Guys and Gals,
    Been thinking about this for awhile, but thought it best to ask the people who really know what they are doing.
    What is the proper way to record & show line numbers in a Master / Detail record set?
    For example, take Master/Detail relationship Orders and OrderItems. Orders has a column Document_Number and OrderItems has Document_Number, Line_Number. Line_Number should contain the row number 1,2,3,4 ... etc. for each row in a document.
    Should I ...
    <ol><li>Add a sequence and a trigger in the database? The FusionOrderDemo does this, but then the sequence never "resets" and I've got row numbers that keep incrementing. So one document has rows 4,5,6 and the next document has 7,8,9 when they should both have 1,2,3.</li>
    <li>Programmatically take care of the row numbers? This seems like I'm asking for trouble. Anytime an insert or delete operation gets done, I'll have to iterate through rows and re-assign row numbers.</li>
    <li>Is there a way to assign row numbers in a table iterator (or data collection?) to an entity?</li></ol>
    Any suggestions would be appreciated. It's looking like #2 is my only option, but if anyone knows different I'd love the input.
    Will

    Thank you both guys.
    As John said, I believe I'm looking for a gap-free sequence per master record.
    The line number of the OrderItems table is the second half of the primary key. The first half of the primary key (DocumentNumber) is the foreign key to the Orders table.
    Think of it like line items on an order or invoice. For example, if you were talking to someone on the phone concerning an invoice, you might say, "The pricing for line item #3 is incorrect." In this case, it's good to have a common reference. Or imagine a Microsoft Excel spreadsheet with no row numbers displayed! You'd never get anywhere if you had to explain something over the phone.
    If this is tricky to perform, I take it using a sequence and trigger such as the Fusion Order Demo is the best way to approach the challenge for simplicity's sake?
    Will

  • What is the proper way to close all open sessions of a NI PXI-4110 for a given Device alias?

    I've found that, when programming the NI PXI-4110 that, if a the VI "niDCPower Initialize With Channels VI" (NI-DCPower pallette) is called with a device
    alias that all ready has one or more sessions open (due to an abort or other programming error) a device reference results from the reference out that has a (*) where "*" is post-fixed to the device reference where and is an integer starting that increments with each initialize call. In my clean up, I would like to close all open sessions. For example, let's said the device alias is "NIPower_1" in NI Max, and there are 5 open sessions; NIPower_1, NIPower_1 (1), NIPower_1 (2), NIPower_1 (3), and NIPower_1 (4). A simple initialize or reset (using niDCPower Initialize With Channels VI, or, niDCPower Initialize With Channels VI, etc.) What is the proper way to close all open sessions?
    Thanks in advance. Been struggleing with this for days!

    When you Initialize a session to a device that already has a session open, NI-DCPower closes the previous session and returns a new one. You can verify this very easily: try to use the first session after the second session was opened.
    Unfortunately, there is a small leak and that is what you encountered: the previous session remains registered with LabVIEW, since we unregister inside the Close VI and this was never called. So the name of the session still shows in the control like you noted: NIPower_1, NIPower_1 (1), NIPower_1 (2), NIPower_1 (3), and NIPower_1 (4), etc.
    There may be a way to iterate over the registered sessions, but I couldn't find it. However, you can unregister them by calling "IVI Delete Session". Look for it inside "niDCPower Close.vi". If you don't have the list of open sessions, but you have the device name, then you can just append (1), (2) and so forth and call "IVI Delete Session" in a loop. There's no problem calling it on sessions that were never added.
    However - I consider all this a hack. What you should do is write code that does not leak sessions. Anything you open, you should close. If you find yourself in a situation where there are a lot of leaked sessions during development, relaunching LabVIEW will clear it out. If relaunching LabVIEW is too much of an annoyance, then write a VI that does what I described above and run it when needed. You can even make it "smarter" by getting the names of all the NI-DCPower devices in your system using the System Configuration or niModInst APIs.
    Hope this helps.
    Marcos Kirsch
    Principal Software Engineer
    Core Modular Instruments Software
    National Instruments

Maybe you are looking for