How to make List.contains(Object) work when you write your own .equals func

I have a list of objcts of a class defined by me. I want to use the List.contains(String name) function to tell me if it contains an object of that name. I have overriden the .equals function as shown in [1]. I then use the code at [2] to to test it, with a bit of debugger output as shown in [3]. It is not working, my overriden method is not getting called by List.contains(String name).
Can anyone tell me how to get this to work?
[1]     @Override public boolean equals(Object esId) {
        if(esId.getClass().isAssignableFrom(String.class)) {
            System.out.println("object name " + this.eslimId + " compare to " + esId + " = " + this.eslimId.equals(esId));
            return this.eslimId.equals(esId);
        } else {
            System.out.println("wrong class");
            return super.equals(esId);
    }[2] graphics.getProcedures() returns private List<ProcedureGraphicSet> procedures;
System.out.println( " graphics.getProcedures().get(0).equals(\"ESLIM_009\")= " + graphics.getProcedures().get(0).equals("ESLIM_009"));
System.out.println( " graphics.getProcedures().contains(\"ESLIM_009\")= " + graphics.getProcedures().contains("ESLIM_009"));[3]
object name ESLIM_009 compare to ESLIM_009 = true
graphics.getProcedures().get(0).equals("ESLIM_009")= true
graphics.getProcedures().contains("ESLIM_009")= false

This is a gross violation of the contract for the equals method, and you are basically getting bitten by that. The equals method must be symmetric, meaning this must hold for all objects A and B:
A.equals(B) == B.equals(A)This does not hold for your equals method because for any string A and custom object B:
A.equals(B) == falseAnd, apparently, the List.contains() method is choosing to compare objects that way.
You must iterate through the list and check the names yourself, or use some sort of functional package which provides a List.contains() type method which takes a Predicate object of some sort.
Edited by: jtahlborn on Feb 11, 2008 11:03 AM
Edited by: jtahlborn on Feb 11, 2008 11:03 AM

Similar Messages

  • How to make a rubber effect like when you swipe between apps using 4 fingers on iPad ?

    Hey guys,
    So how to make a rubber effect like when you swipe between apps (first or last app) using 4 fingers on iPad iOS7 ? Any examples ?
    Thanks!
    Ivan

    Please do not double post the same question.
    Just like I said before. Animate X scale and position. Set the anchor point of the left image to the left side. You can then use an expression or just generate keyframes for scale. When you flip to the next screen then animate position. Easy basic animation except for the bounce. Key framing the bounce so that it looks natural takes a lot of experience or an expression.
    Google bounce expression after effects and find this. http://www.motion-graphics-exchange.com/after-effects/Wiggle-rubber-bounce-throw-inertia-e xpressions/4ad0f32a944ad
    There are a bunch of other solutions.
    There is no single click solution to this problem and it is not an effect, it is an animation.

  • Moving original files when you use your own folder structure

    I currently maintain my own folder structure (on the HDD) for Aperture to read files from (rather than allow it to create its own complicated structure). Based on what i have seen so far, I understand that Aperture links its project with the HDD folder from where you import images.
    In an instance, where I moved my file from the HDD folder structure, the image still appears in Aperture, but with a yellow question mark, and it does not allow me to edit it. Here I am assuming that since i moved the file from its HDD folder, Aperture is no longer able to locate it. Hence, I have the following queries about moving/ deleting files from my HDD:
    Q1: If I want to move a file from one HDD folder to another, how do I do so without losing its link in Aperture
    Q2: How do I completely delete a file from my HDD using Aperture? Assume here that I have imported it into Aperture but haven't made any changes to it, which means that I have only one version, the master version. Currently, when I delete it in Aperture using 'Delete version', I notice that the file still exists in the HDD folder). Is it that the only way to delete a file is to do so first from Aperture and then use Finder to delete it from the HDD folder? If not, whats the best way.
    Q3: There is another scenario for Q2 - If I have made changes to a file after importing it in Aperture, there are now two versions, master version and edited version. If I want to delete both these files, whats the best way to do so.

    OK let's take a step back here.  In your previous post you wrote asking how to move a file from one folder on your HD to another so that Aperture wouldn't loose track of it. And for that we answered to use File->Relocate Masters. The last two questions concerned deleting images from both Aperture and the HD. And we covered that.
    Now you write:
    f i want to move my master and version files from one project to another (and the corresponding master files too), i should first move the master files using File> Relocate master and then drag-drop the versions from within Aperture. (I usually maintain similar names for my HDD folders and corresponding projects in Aperture, hence if i move the master, then it makes sense to move the versions too).
    Now you're bringing in  moving images in Aperture from one project to another.  What you are saying is correct but bear in mind:
    The library structure inside Aperture is totally independent of the file structure you use to store referenced masters on the HD outside of Aperture.
    Now It is possible to have one mimic the other as you seem to be doing but for all intents and purposes Aperture doesn't care at all how the external file structure appears as long as Aperture knows were the masters are.
    So if you want to move masters INSIDE of Aperture from one project to another you can simply drag the visible image from the source project to the destination project. All versions will come along, versions are coupled to their masters and as such can't be moved independently. Any versions in Albums will continue to point to the master they came from.
    Now if you want to move the master files EXTERNAL to Aperture you need to use the File->Relocate Master command so that Aperture will know were the files are.
    Note: there is another command File->Locate Referenced Files that is used to connect Aperture to its referenced masters if the connection between the two is somehow broken. As for example what would happen if you moved the referenced masters using the finder rather then the Aperture command.
    So you should be good to go, just remember that the two structures, Aperture library and referenced files, are independent and don't really need to be kept in sync. And by doing this you're  making extra work for yourself that isn't really necessary.
    regards

  • Can you make bootcamp come up everytime when you start your computer so you are able to select which OS you want to load up?

    Is there an option to select to get the bootcamp selection screen to come up everytime i start my mini?

    Hi,
    rEFIt http://refit.sourceforge.net/ is one possibility.
    BootPicker http://www.apple.com/education/resources/bootpicker/ is another one.
    Regards
    Stefan

  • How to add a container object in a station globals

    Hi,
    How to add a container object in a station globals

    Hi radlou,
    This might be what you're looking for:
    NewSubProperty Method
    Syntax
    PropertyObject.NewSubProperty ( lookupString, ValueType, asArray, typeNameParam, options)
    Purpose
    Creates a new subproperty with the name the lookupString parameter specifies.
    Parameters
    lookupString As String
    [In] Pass the lookup string for the new subproperty to be created. If you pass a lookup string with multiple levels (such as "x.y.z"), this method creates all of the necessary intermediate container objects. Refer to lookup string for more information about the strings you can use.
    ValueType As PropertyValueTypes
    [In] Pass the type of value you want the new subproperty to store.
    asArray As Boolean
    [In] Pass True to make the new subproperty an array whose elements are of the type you specify in valueType.
    typeNameParam As String
    [In] Pass the name of an existing type if you want to create the new subproperty as an instance of a named type. Otherwise, pass an empty string. If you pass a type name, you must pass PropValType_NamedType for the ValueType parameter. Refer to NamedPropertyTypes for a list of built-in named types.
    options As Long
    [In] Pass 0 to specify the default behavior, or pass one or more PropertyOptions constants. Use the bitwise-OR operator to specify multiple options. You do not need to pass the InsertIfMissing option to create the new subproperty. Pass DoNothingIfExists if you want the method to not report an error if the subproperty already exists.

  • How to make a button stay down when I click on it in  CSS nav bar.

    So I have created a horizontal navigation bar, I use the CSS
    Sprites/Pixy method to get the hover working with the same image as
    the link/in active stage of the buttons.
    Now how do I make the button stay down when someone click on
    them?
    These are the codes for the nav bar.
    #nav{
    width: 780px;
    list-style: none;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    padding: 0;
    height: 40px;
    #nav li{
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold;
    float: left;
    padding: 0;
    #nav a{
    width: 125px;
    display: block;
    color: #000000;
    text-decoration: none;
    text-align: center;
    background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    background-repeat: no-repeat;
    background-position: center 2px;
    padding-top: 14px;
    padding-bottom: 10px;
    background-color: #000000;
    #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    #nav a:hover{
    background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    background-repeat: no-repeat;
    background-position: center -36px;
    color: #FFFFFF;
    width: 125px;
    padding-top: 14px;
    padding-bottom: 10px;
    background-color: #000000;
    Everything works so far, the hover works when you roll the
    mouse but when you click the button goes right back.
    How can I make it stay down and then go back to normal when
    you click on another link/button?
    Thanks very much.
    Patrick

    Read my suggestion again. You are missing a critical point. I
    show you
    exactly where to put the stylesheet. And it doesn't matter
    how many
    stylesheets you have on a page.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Webethics" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Change this -
    >
    > #nav a{
    > width: 125px;
    > display: block;
    > color: #000000;
    > text-decoration: none;
    > text-align: center;
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center 2px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    >
    >
    > #nav a:hover{
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center -36px;
    > color: #FFFFFF;
    > width: 125px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > to this -
    >
    > #nav a{
    > width: 125px;
    > display: block;
    > color: #000000;
    > text-decoration: none;
    > text-align: center;
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center 2px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    >
    >
    > #nav a:hover{
    > background-position: center -36px;
    > color: #FFFFFF;
    > }
    >
    > Then on each individual page, change this -
    >
    > </head>
    >
    > to this -
    >
    > <style type="text/css">
    > #nav a#link4 {
    > background-position:center - 36px;
    > }
    > </style>
    > </head>
    >
    > (for link4, for example)
    >
    >
    > --
    > Murray --- ICQ 71997575
    > Adobe Community Expert
    > (If you *MUST* email me, don't LAUGH when you do so!)
    > ==================
    >
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    >
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    > ==================
    >
    >
    > "Webethics" <[email protected]> wrote
    in message
    > news:[email protected]...
    > >
    quote:
    Originally posted by:
    Newsgroup User
    > > When they click on a button, do they go to another
    page? And is each
    > > button
    > > uniquely identified?
    > >
    > > If so, then put a little stylesheet on each such
    page that sets the
    > > particular button to the down sprite settings,
    e.g.,
    > >
    > > a#link6 { downspritevalues }
    > >
    > > --
    > > Murray --- ICQ 71997575
    > > Adobe Community Expert
    > >
    > >
    > > This is the link to the page.
    > >
    http://www.patrickjudson.com/zitto_web1d.html
    > > What state do I use to get this effect? The active
    or the visited?
    > >
    > > I want the buttons to remain down when click or
    even better, how do I
    > > get
    > > the
    > > welcome button to appear down when a person visits
    the page to show them
    > > they
    > > are at the home page.
    > >
    > > Thanks so much. Patrick
    > >
    > >
    > >
    >
    >
    >
    > Hey! Murray, thanks very much for the efforts. However
    I'm still confused
    > as
    > to where to insert the individual styles on each page.
    >
    > The pages already have a style sheet, in fact they all
    share the same
    > style
    > sheet. The following codes below is what you instructed
    but I'm confused
    > as to
    > where to insert them since the page already has a head
    opening and closing
    > as
    > well as a style opening and closing tags. Can you please
    add the codes you
    > instructed so I can see where they go and how to
    implement them?
    >
    > Thanks - Patrick
    >
    >
    > Then on each individual page, change this -
    >
    > </head>
    >
    > to this -
    >
    > <style type="text/css">
    > #nav a#link4 {
    > background-position:center - 36px;
    > }
    > </style>
    > </head>
    >
    > (for link4, for example)
    >
    >
    >
    >

  • How to make VPN client auto timeout when it still idle?

    How to make VPN client auto disconnect when it still idle?
    Hi,I found some user still connected the VPN evenif they dose not use the VPN resouse.
    I try to set a "idle timeout" for the VPN configuration.
    We use PIX515 8.0.3 and CISCO ACS 4.2 for the VPN's connection and authentication,and the user use cisco vpn client for the connection.
    I have tried many methods,but all failured.
    First,I configed "vpn-idel-timeout 5" on PIX.It can not worked.
    so,I add Radius(CISCO VPN 3000/ASA/PIX 7.0+) attribute "[026/3076/050] Authenticated-User-Idle-Timeout" on CISCO ACS,It still not worked.
    And I also add IETF RADIUS Attributes "[028] Idle-Timeout" on group setting on ACS,it always not worked.
    i found in vpn client's statistics,it always has some byte sended or received, i thought it maybe IPsec keepalive message or Radius message.
    This maybe the reason because the PIX or ACS think the vpn user is keep working.
    Can someone tell me how to make a "idle time out"?
    best regard.
    Roger

      here is the configuration on PIX,
    group-policy DfltGrpPolicy attributes
    wins-server value 10.0.0.67 10.0.0.68
    dns-server value 10.0.0.67 10.0.0.68
    vpn-simultaneous-logins 20
    vpn-idle-timeout 5
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value vpn-acl
    default-domain value mydomain.com
    address-pools value vpnpool group-policy DfltGrpPolicy attributes
    wins-server value 10.0.0.67 10.0.0.68
    dns-server value 10.0.0.67 10.0.0.68
    vpn-simultaneous-logins 20
    vpn-idle-timeout 5
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value vpn-acl
    default-domain value want-want.com
    address-pools value vpnpool

  • How to make the backlight stay on when charging? N...

    Hi
    How to make the backlight stay on when charging?  or it is not possible?
    Thanks  

    Did you select HIDE under the Options (in the application) ? Its working fine on my Nokia 5800xm
    There is one more.. KeepItOn also available at OVI Store..
    --------------------------------------------------​--------------------------------------------------------​--------------------------------------------------​--If you find this helpful, pl. hit the White Star in Green Box...

  • How to make third party cables work on iphone?

    I have been using the original Apple charger cable that came with my phone (iPhone 5C) for a good year, but then it broke. So I bought this non-Apple cable because I didn't really wanna spend a lot of money for an original one. I have already charged my phone with third-party cables before, so I thought it would work. The first time I used the non-Apple cord, there were minor difficulties because I had to plug and un-plug it several times before it actually charged. 2 days later, I plugged an original cable (which was my sister's) to charge my iPhone. Obviously, it worked. But later on, when I went to charge my iPhone with the non-Apple cable, a message popped up (This accessory may not be supported). I dismissed it, thinking it would still charge. No such luck. I tried to unplug and plug it, but still, it won't charge. Now, I have to charge through my laptop. Can anyone tell me how to make third-party cables work? I don't really wanna bring my laptop everytime I charge. I'm planning to only use this cable until I get my hands on an original one. Please help.

    Are you seeing the EE (or T-Mobile) network name and network bars in the top right hand corner of the screen?  Turn off WiFi (Settings>WiFi - turn this off).  Is there anything next to the network name in the top right hand corner (3G, E or o)?  E is Edge and o = GPRS.
    If there's nothing next to the network name, turn off the iPhone and then turn it back on.  To do this, press and hold down the button on the top until you see the 'Slide to Power Off' message.  Slide and then wait for the iPhone to shut down.  To turn it back on again, press and hold the top button again unti lkthe Apple logo shows on the screen.
    EE and signal bars top left = Yes
    Turned off Wifi and next to the EE is 'o' which you say is GPRS? What does that mean please??
    Got this reply from another forum but still no success???

  • How to make material availability check work during Work Order creation

    Hi Experts,
    Kindly advice about these matters:
    1. How to make material availability check work during Work Order creation?
    My requirement is Work Order can not be created when it has missing parts. I have set the config to '3' can not created when is has missing parts, but it still does not work.
    I have implemented SAP Notes 1148139 on my system (SAP ECC 6 Ehp 5) also, but still does not have any effect.
    I must not set the config Res./Purch Doc creation to 'immediately', because it does not fit to my user requirement. Is there anyone knows how to solve this requirement?
    2. How to make information message/ Availability check screen appear when sparepart is missing, without clicking Availability Check button? for example: appear when clicking Save button.
    Thank you
    -amoonra-

    Hi Maheswaran,
    I have implement the prerequisite notes. (Notes 790219 and 1034962). Do you know why it is still does not work?
    Thanks
    -amoonra-

  • How to make the mobile application work with firewall and anti-virus ON

    Hi,
    I keep on receiving internal processing error when i try to login sap mobile solution 1.3.0 on my ipad and i was provided a solution, that is to turn off my firewall and antivirus. I works by turn off both of it but i cant possible turn of the firewall and antivirus on the server.
    Can anyone guide me how to make the mobile application work with firewall and anti-virus ON
    Thank you

    Dear Rajesh,
    Create a policy in your fire wall to allow the port to send and receive data.
    I believe the port for the mobile should be port 8080 and 8443.
    And your license server port 30000 and 30001
    nd.Q

  • My transparency does not work on my iPhone and I was wondering how I fix that? It worked when I first downloaded ios7 but not now.

    My transparency does not work on my iPhone and I was wondering how I fix that? It worked when I first downloaded ios7 but not now.

    Hello wilsontot_too,
    Thank you for the details of the issue you are experiencing on your iPhone.  It sounds like you are not noticing transparency on your iPhone.  It may be that you have "Increase Contrast" turned on in your iPhone settings.
    I recommend verifying that Increase Contrast is turned off in Settings>General>Accessibility.
    iPhone User Guide - Large, bold, and high-contrast text
    http://help.apple.com/iphone/7/#/iph73b89c6
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?

    My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?And all the sounds on my phone are on, even the keyboard clicks.

    Try restarting your iPhone by holding down the on/off and the home buttons at the same time until you see the Apple logo, double check the volume button just in case.  If you still can't hear the tones go into your settings>sounds and make sure the options are on. 

  • How to make icons of photos bigger when selecting to attach to email?

    how to make icons of photos bigger when selecting to attach to email?

    Changing the DPI to 120 won't affect the font size of the menu bar in the Editor.  See this FAQ for what happens when you change the DPI:
    http://www.johnrellis.com/psedbtool/photoshopelements-6-7-faq.htm#The_Organizers_Menu_Bar_ doesnt_show

  • How to make a Button to work Actively even if there is a mandatory field..?

    Hi All..
    How to make a Button to work Actively even if there is a mandatory field to be fulfilled..???
    I am badly in need of this logic, as i have to incorporate in my code..
    Points will be rewarded without fail..

    Hi Pavan,
    I also faced the same requirement. U can do one thing like remove the obligatory keyword of that parameter/select-option. U can handle the same using the program in at selection-screen event. See this sample of code,
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_land1 for T005-LAND1 <b>[Needs to be mandatory]</b>                 no intervals no-extension.
    SELECT-OPTIONS:  s_panid FOR zoindex_val-zopanid.
    SELECT-OPTIONS:  s_effdat FOR zoexchrate-zedate.
    SELECTION-SCREEN END OF BLOCK b2.
    *-- AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
    *-- Obligatory Country Code
      IF s_land1[] IS INITIAL.
        MESSAGE e050 WITH text-050.
                     "Please select the Country Code
      ENDIF.
    So whenever u do F8/Enter other than that push button, it will prompt u to enter the country code first then only u can proceed.
    Hope this would help u in some way. Please do reward the helpful answers.

Maybe you are looking for