Can you safely cast Object to generic Set MyType ?

I have a property change event evt where evt.getNewValue() contains a Set<MyType> value and I want to do the following:
Set<MyType> newSet = (Set<MyType>)evt.getNewValue();
Is there a "safer" way of doing this which satisfies the compiler enough to prevent the unchecked warning?
Before going any further and replying with something like MyType<T> is lost at runtime, I want to add that I can do:
MyObject<MyType> myObj = new MyObject<MyType>();
as well as:
MyObject<MyType> myObj = createMyObj(MyType.class);
{.. and somewhere alternatively: return clazz.cast(o); }
So why can't I do something similar with Set<MyType> such as:
Set<MyType> newSet = Set<MyType>.class.cast(evt.getNewValue()); // compile error obviously.
I suppose I'll just have to go with:
Set newSet = (Set)evt.getNewValue();
for (Object o : newSet)
MyType myType = MyType.class.cast(o);
}

This would only be helpful, if one also changes the PropertyChangeListener interface topublic interface PropertyChangeListener<T> {
  void propertyChange(PropertyChangeEvent<T> evt);
}making it parametrized by the Type of values so the listener can receive type-safe events. If you don't, you will have the same problem as the OP with casting to the parametrized event type.
Same, if one only uses a wildcard for the parameter's type.
Of course, doing so is possible for your own classes, if you do not have to be compatible with any Swing or AWT code. One would have to implement specific listeners for each type of evented value, though, as it is not possible to implement the same interface more than once having different parameterizations. It seems by far more overhead and complex than simply checking and casting the value received by the event.

Similar Messages

  • How can you move the objects from one server to another?

    how can you move the objects from one server to another?

    Hi,
    Collecting objects for Transporting
    1. rsa1->transport connection
    2. left panel choose 'object type', middle panel choose 'infocube' and 'select objects'
    3. then choose your infocube and 'transfer'
    4. will go to right panel, choose collection mode 'manual' and grouping only 'necessary objects'
    5. after objects collection finished, create request
    6. If they are $TMP, then change the package.
    7. When you click the Save on the change package, it will prompt for transport. Here you can provide an existing open transport request number, or if you like here itself you can create a new one.
    8. You can check the request in SE09 to confirm.
    Releasing Transport Request  
    Lets say you are transporting from BWD to BWQ
    Step 1: In BWD go to TCode SE10
    Step 2: Find the request and release it (Truck Icon or option can be found by right click on request #)
    Note: First release the child request and then the parent request
    Steps below are to import transport (generally done by basis )
    Step 1: In BWQ go to Tcode STMS
    Step 2: Click on Import queue button
    Step 3: Double Click on the line which says BWQ (or the system into which transport has to be imported)
    Step 4: Click on refresh button
    Step 5: High light the trasnport request and import it (using the truck icon)
    Transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/0b/5ee7377a98c17fe10000009b38f842/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/224381ad-0701-0010-dcb5-d74236082bff
    Hope this helps.
    thanks,
    JituK

  • How can you safely clean your magsafe and other ports on a macbook pro?

    How can you safely clean your magsafe and other ports on a macbook pro?

    MagSave, yes. Other ports cannot be safely cleaned although you can blow air in to clean out dust.

  • Can you safely power off a Airport 5th generation and attached disk drive without risking data getting lost??

    Can you safely power off a 5th generation AirPort and an attached disk drive without losing data?

    I'd like to just be able to shut it down by tripping off the power strip the disk and airport are attached to with my toe so they're not sucking down power at night or when I'm at work.     I wouldn't mind a sequence of power down the computers on the net first and then 'toeing off' the AirPort+disk.  
    I'm just wondering how quickly between the time that I power off the mac that the airport would flush all of its buffers.

  • Can you destroy an object?

    I have been looking around for an answer to this question a little while and have also posted on the Java .net forums too.
    But Im writing a little game where things appear on the screen, then because of user interaction, they dissapear. simple enough, I have my objects stored in a sequence, that I bind to a Group{} in my main Frame.
    The issue is that each of these objects get removed from the game via the *delete sequence* code segment and because they have their own timelines which does its own collision detection, the object never seems to get de-referenced and after a while I get out of memory exceptions and the game slows down to a halt.
    Firstly, I added functions to stop all timelines in each element before deleting it from the sequence, but it didnt appear to work as the game still slows down.
    So my question is, can you destroy an object? I just need it gone completly, and if there is a work-around, how can I be sure that it works? Currently the netbeans profiler isnt too easy to read, but that just maybe me (anyone else having issues reading the results of a JavaFX profiled app?)
    Thanks for any help that you can think of...
    Mark

    Are you 100% certain that there are no references to the object left after you remove it from the sequence? There is no way to explicitly destroy objects in Java; and this behavior extends to JavaFX. If you check the code and you're 100% sure that no references are left hanging out there, check Jira.
    [http://openjfx.java.sun.com/jira/|http://openjfx.java.sun.com/jira/]

  • Can you please help me regarding Generic data  Source

    Hello Friends,
    I have done generic delta source , In that i found
    1) Timestamp
    2) 0calday
    3) Numeric Pointer
    Can you please explain me
    And also
    Update modes :
    Additive Delta
    New Status for Changed records
    Thanks
    PP

    Hi,
    If u want ur data source is delta enabled u vl come up vt these terms.
    There are various delta processes for SAP source systems:
           1.      Forming deltas with after, before and reverse images that are updated directly in the delta queue; an after image shows the status after the change, a before image the status before the change with a negative sign and the reverse image also shows the negative sign next to the record while indicating it for deletion. This serializes the delta packets. The delta process controls whether adding or overwriting is permitted. In this case, adding and overwriting are permitted. This process supports an update in an ODS object as well as in an InfoCube. (technical name of the delta process in the system): ABR)
           2.      The extractor delivers additive deltas that are serialized by request. This serialization is necessary since the extractor within a request delivers each key once, and otherwise changes in the non-key fields are not copied over correctly. It only supports the addition of fields. It supports an update in an ODS object as well as in an InfoCube. This delta process is used by LIS DataSources. (technical name of the delta process in the system): ADD)
           3.      Forming deltas with after image, which are updated directly in the delta queue. This serializes data by packet since the same key can be copied more than once within a request. It does not support the direct update of data in an InfoCube. An ODS object must always be in operation when you update data in an InfoCube. For numeric key figures, for example, this process only supports overwriting and not adding, otherwise incorrect results would come about. It is used in FI-AP/AR for transferring line items, while the variation of the process, where the extractor can also send records with the deletion flag, is used in this capacity in BBP. (technical name of the delta process in the system): AIM/AIMD)

  • Can You Change 3D Object Rotation Axis?

    Greetings. I have created a 3d object using repousse in Photoshop (CS5 extended). The original 2d image was created in Illustrator. I have found that in both Photoshop and After Effects, when I rotate this object in 3D space, either rotating the object itself or the camera, that the axis upon which it rotates is not the 3D center of the 3D object, but rather somewhere behind it. The result is that it is rotating like the moon rotates around the earth, rather than rotating in place, like an eye moving (rotating) in an eye socket; i want the eye ball to stay in one place, but see the pupil move up and down and all around like a real eye would.
    I have had no luck changing anchor points or positions of the object, even though I do have the X, Y, Z coordinates to manipulate.
    Can you tell me how to adjust this anchor point, or rotation axis point, or whatever this would be called?
    Thanks.

    Not really true...
    Yes it is limited but it can be altered.
    I believe that photoshops 3d center point is based on the world center and not the objects center. This means that it is possibloe to move the object to the world center to fix the rotation of your object.
    Open window>3d panel and just below the layers in that panel are some icon at the left side of the panel. Third icon down is the mesh tool, hold down the mouse button to bring up the pop up menu. Select the slide mesh tool. This will let you move the mesh adjust the pivot point.
    The problem that I see with this, is that it is trial by error, I do not see away to visually see where the world center is.
    Scratch that, at the bottom of the panel are three icons. The left of the three will turn on the ground plane. The plane does show world center.(where the red and green lines intersect is world zero)
    To understand which axis is which, sinse it does not specify.  Select the 3d pan tool, then in the top tool bar, type in a value one axis at a time to see which direction the object is moving. Then repeat the process for the rotate tool and see how the object rotates around each axis.

  • Question? Can you safely delete huge media cache files?

    Dear Experts:
    In working with PRE7 I found that almost all of my disc space was contained in my media cache folder and it was clogging up all my work. What is that file and can it be deleted without causing harm or losing work?
    Tom

    Tom,
    This can depend a bit. If you have done any Rendering, those Render files can be safely eliminated. As mentioned above, the .CFA's and PEK files can also be eliminated (will be regenerated, if needed).
    For housekeeping, I place all Scratch Disk files in the Project's folder hierarchy. This keeps everything together and below the Project's root folder. When I am done, I will just Delete everything in that Project. In my case, ALL Imported Assets are ONLY copies. I never work with originals, which are safely stored elsewhere. Basically, one click takes care of the cleanup.
    If I am not sure that I am done forever with the Project, I will first use the Archiver (Project Manager in PrPro), and locate the "archived" Project on an external HDD for storage. I will archive ALL aspects, except for the Render files, including the .CFA's and .PEK's, just to save time, should I need to revisit that Project.
    There are other files, that are possibly in the Project's root folder, such as when you Burn to Folder. You will then have the VIDEO_TS folder, with the necessary DVD-Video files. Once you have successfully burned that folder to DVD-Video, the VIDEO_TS (and all files), can safely be Deleted.
    Hope that this helps,
    Hunt
    PS - UNTIL I am 100% certain, that I am done, I do not Move, Rename or Delete anything. When done, I often use the above mentioned Archiver, and then do major clean up.

  • Can you Manipulate 3D object in Director Dynamically?

    Greetings,
    I am looking for some way to dynamically manipulate a 3d
    object and am wondering if Director 3d has the ability to do this
    and if so, if any of you want to take this on as a freelance
    project? (this is a serious request on a cool project, not some
    hokey offer)
    I had first hoped that Flash could do it since I am more
    familiar with flash, but I was wondering if Director can update a
    3d object on the fly as it gathers new values for a number of
    points in the 3d object. Can Director do this?
    If you know of any person, any business that knows how to do
    this PLEASE contact me to discuss more. It has been difficult for
    me to understand the capabilites of Director 3D without speaking to
    someone who is talented and competent as I am sure most of you are.
    Cheers,
    -i

    model position, model rotation, model location, model scale,
    model shader, etc. are all easily modified. the actual mesh that
    makes up the model's shape can be changed with the meshdeform
    modifier. however, these changes won't be permanent. the entire 3d
    scene will be in it's original state everytime the movie starts. if
    you want to save state you'll have to store the data defining the
    attributes externally in some way and apply them at runtime.

  • Can you Dynamically Name Objects

    I am trying to create a new object for every line of a text file, that i read in.
    The problem is that i need to dynamically name this object because i dont know the number of lines in the file.
    I tried using a varible as the object name but it errors as it sais that varible is already declared as a diffrent type.
    String newObject = "object1";
    myObject newObject = new myObject();
    If this is not posible can i rename an object after it is created.
    Thanks for any help.
    Rob

    hi!
    I know this problem..but it's not a problem of java, it's a problem of your thinking! I had it too when I started programming in java, because I came from programming in PL/1... ;-)
    and the answer I think is NO, it's impossible.
    you think you have to create and rename an object..probably you have an object james and you want to rename it into joseph.. but if you have a class person and a method calles setName(String name), you can change the name in this way..
    if you want to create a lot of new objects use an array or better a Vector.
    I hope this helps..
    http://www.menzsoft.ch

  • How to set the Health app on my iPod touch(5th gen.)? Can you please tell me how to set it step by step ? Thank you ️

    I've been trying to set my health app since it came out with IOS 8. But every time I selected my data and everything , nothing happened.
    Can you please tell me exactly how to set it ?  

    Maybe:
    Use Health on your iPhone or iPod touch with iOS 8 - Apple Support
    http://www.cnet.com/how-to/apple-health-app-how-to-set-up-import/
    http://blog.human.co/posts/human-ios-health.html
    Not that all feature re not available on an iPod.
    If you have problem please provide more details of your problem. Like what you did, what you tap and what happened or did not happen

  • Can you change still clip duration default setting?

    I create wedding videos, and at the end of my movie I add about 100 still clips as edited highlights. In older versions of imovie you were able to alter the length of still clips created in the preferences to whatever time you wanted. In this newer (better?!?) version when I have created all my still clips I have to click on each one individually to alter the time duration. The default setting is 5 seconds and I can't find anywhere that you can change this. It takes me AGES to do this individually, anybody got any ideas of a better way? Cheers.

    I can't necessarily recommend this for it can lead to project corruption. It's possible to manually edit the text of the iMovie project file, changing the playtime duration of all your still clips to the duration you want.
    1. In iMovie, double-click on one of your still clips. Write down the name of its source file. Quit iMovie 6.
    2. In the Finder, make a duplicate of the project. Work on the duplicate.
    3. In the Finder, open the duplicate project package. (Control-click on the project icon and choose "Show Package Contents" from the popUp menu.)
    4. You'll see two iMovie project files loose in the window that opens, plus some folders. One of the project files has a tilde (~) in its name and one does not. Our goal is to edit the file that does NOT have the tilde. (The tilde file is type of backup.)
    5. Launch TextEdit. (In your Applications folder.) Drop the non-tilde project file onto the TextEdit icon in the Dock.
    6. Use TextEdit's search function to search for the string that defines the play-time of each still clip, now 5 seconds. For PAL, that string is "<integer>125</integer>". For NTSC, it is "<integer>150</integer>".)
    7. For each still, you want to change the 125 to some other number. For PAL, the number you want is 25 X the number of seconds to play.
    If the only clips in your project that play for 125 are your stills, you can safely use the Replace All command to replace all with the strings at the same time. Be sure to include the tags <integer> and </integer.
    If there are others that play for 5 seconds, you'll need to examine each clip individually, using the sample name you wrote down to see if the clip uses a similar name.
    8. Save the modified file and close that TextEdit window.
    9. Go back to the Finder and double-click on the project package to open it in iMovie 6. If everything worked as intended, all your stills should play with a new length.
    Karl

  • Warning when casting object into generic type at run time.

    I am getting this message when casting an object at run time:
    Type safety: The cast from Object to Tree<V> is actually checking against the erased type TreeI'm overloading an equals(Object o) method in my class.
    Is there a way to get rid of the warning (besides turning the warning off :))

    I'm overloading an equals(Object o) method in my
    class.
    Is there a way to get rid of the warning (besides
    turning the warning off :))No. The best you can do is what is demonstrated in the previous link.

  • Can you remove the camera white balance setting in Aperture

    I have a Canon 7D and use Aperture for processing and storing my images.
    With the Canon I shoot both video and still and frequently adjust the white balance in the camera.  I make a frequent mistake in leaving the wrong white balance setting on - eg when taking video indoors in the evening  I set the white balance to indoors (the Canon seems poor at white balance decision making on video) and then I forget I'm not using auto white balance and switch to taking a photo with flash.  The result is a horrible blue photo - which if I don't spot the problem at the time seems very hard to correct afterwards.
    I use the Aperture white balance adjustments frequently but unless there is a patch or white or grey I an use the dropper on, I find this particular situation seems to be right off the scale of what I can fix in Aperture.  I end up with sliders at the extremes of the scales and no intuitive sense of what numbers to type in manually to try and get realistic colour - so I often end up discarding these photos even if the shot itself is something I'd like to use.
    So my question is given I'm importing RAW, is there a way to show the phoo without the (wrong) white balance setting I applied in the camera, to let me choose white balance from scratch?
    Or if not, do you have any advice about how to adjust from this very bluey unrealistic colour of image?

    Kirkby - thanks for the quick reply.
    Didn't know you could drag inside a value field - that's helpful.
    But being able to get different numbers on the slider isn't the root of my problem.
    In a specific example I have two photos - one taken with white balance set to flash and the photo was with flash, where after a bit of tweaking to get the colour I want the temp slider is at 5000K (and tint 0).  The second photo has my shooting error with interior lighting white balance but taken with flash.  The two shots were taken from almost the same point of the same view (but different people in frame).  The shot with the white balance error comes off camera horribly blue coloured. I can fiddle with the two sliders - I take temperature to 20000K and tint to 40 to do the best with it I can, and with those settings one of the two faces is approaching flesh colour but the wall behind the subjects (which is a light blue in reality) is now appearing light yellow in places.  I just can't get a good looking colour effect no matter ow extreme the slider settings.
    I may have phrased my question badly - as I totally agree you can't show a raw without a colour setting - so maybe I'm better asking to be able to use a different colour setting on the raw data rather than having to start with adjustments on top of my white balance mistake.
    Given the two shots were in the same place against the same background and the same lighting (both with flash) it seems to me I ought to be able to get a similar colour effect on both and I just can't.  To illustrate here are the two photos (the one on the left was shot with flash wb and in Aperture I'm viewing it with 5000K and 0 tint, the one on the right was shot with indoor wb and in Aperture I'm viewing it with 20000K and 40 tint and it looks terrible!)
    https://www.box.com/shared/qle3t6ovyhrd1egez3vc

  • Can you create an object from a string

    I have been working on creating a dynamic form, creating the
    form items from an xml file. I am getting very close to conquering
    this task. I will share it when it's complete.
    However, I am stuck at the moment trying to create an object
    from a string. For example, if the xml item is an HBox I want to
    create an HBox. Like this: parentObject = new arrayOfFormItems[
    index ]..type ()
    This isn't working. First, is this possible using some syntax
    I am unaware of in Flex? I don't want to use a large if or case
    statement if possible.
    Thanks in advance for your help!

    Thank you very much. Indeed that did solve the one problem. I
    missed the casting as a Display Object. That is awesome!
    I do still however, have to instantiate one of every item I
    want to dynamically create or I get the following error when I try
    to create a dynamic object that I have not instantiated before.
    ReferenceError: Error #1065: Variable HBox is not defined.
    at global/flash.utils::getDefinitionByName()
    at MyForm/buildForm()
    at DynamicForm/::onComplete()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    I read that you have no choice but to instantiate one of each
    type to force the linker to link the code for that class into the
    .swf. Unless you know another way to force it.
    This is what I have in my Application mxml to get it to work:
    <mx:HBox>
    <mx:Text visible="false"/>
    <mx:TextArea visible="false"/>
    <mx:TextInput visible="false"/>
    <mx:DateField visible="false"/>
    </mx:HBox>
    And those are the types I'm using to test with. . . I will
    have to add all the others I want to use as well . . .

Maybe you are looking for