Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use this? public <R extends IPCMessage> R sendAndGetResponse(IPCMessage msg)
    primarykey
    data
    text
    <p>I've been writing Java swing GUI code for several years but the following syntax stumps me. I'm talking about the " &lt; R extends IPCMessage > R" portion of the method below. I found this in a library another engineer wrote and I have no idea how to use it. </p> <p>I'm very familiar with the other uses of generics but this one I don't know. </p> <p>Can someone explain what is going on and how I can use it?</p> <p>Thank you.</p> <pre><code>/** * Sends the specified IPC message to the process the IPC instance is * connected to * * @param msg * the IPC message to send * @return IPCMessageRx for the received response message if want_resp is * true null if want_resp is true and no response was received * within the timeout null if want_resp is false * @throws InvalidCastException if the return type doesn't match the actual * type of the response. */ @SuppressWarnings("unchecked") public &lt;R extends IPCMessage&gt; R sendAndGetResponse(IPCMessage msg) { logger.logTrace("IPClient::sendAndGetResponse: entered, msg = \"" + msg.toString() + "\""); // keep track of whether the message sent boolean msg_sent = send(msg); // if the message sent and a response is wanted, try to get one from the // received message buffer IPCMessage back = null; if (msg_sent == true) { back = receive(msg.getSequenceNumber()); } if (back == null) { logger.logDebug("IPClient::send: exiting, back = null"); } else { logger.logTrace("IPCClient::send: exiting, back != null"); } return (R)back; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload