Relates :
|
|
Relates :
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST : The Buffer class has been designed with method chaining in mind. E.g. method.flip() simply returns the Buffer it is part of. However when calling method that have been defined (and not overwritten) in e.g. ByteBuffer, the return type is a Buffer instead of the type of the underlying class, ByteBuffer. To retrieve the ByteBuffer again it is required to perform a cast - but that makes the method chaining almost unusable. As the methods to get values from the Buffer are actually defined in the subclasses (mistake in the class design?) the cast is required to do anything useful after calling e.g. flip() almost all of the time. PS willing to write the source code to retrofit Buffer with the type argument. JUSTIFICATION : Fulfil the promise inherent in the design of Buffer to be able to perform method chaining. Making clear in the API that e.g. flip() does not return just any Buffer but the instance that the flip() is called on. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - int i = intBuffer.flip().getInt() ACTUAL - int i = ((ByteBuffer) (intBuffer.flip())).getInt() ---------- BEGIN SOURCE ---------- int i = intBuffer.flip().getInt() Fails to compile. ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : int i = ((ByteBuffer) (intBuffer.flip())).getInt(); or intBuffer.flip(); int i = intBuffer.getInt();
|