Ben Weidig created TAP5-2764:
--------------------------------

             Summary: JSONArray improvements
                 Key: TAP5-2764
                 URL: https://issues.apache.org/jira/browse/TAP5-2764
             Project: Tapestry 5
          Issue Type: Improvement
          Components: tapestry-json
            Reporter: Ben Weidig


The following improvements should be added to JSONArray:

*Implement {{List<Object>}}*
Right now, the type implements {{Collection<Object>}} but it could bei a 
{{List<Object>}} instead.
As it's a thin wrapper arround {{ArrayList<Object>}} anyway, using a more 
feature-packed interface makes sense, as there's almost no additional cost to 
it.

*Fix {{Object remove(int)}} contract*
Index-based removal is a {{{}List{}}}-related method with a certain contract, 
like throwing an Exception on invalid index arguments.
Event hough it _should be_ expected behavior on any {{{}List{}}}-like data 
structures, it's going to be a breaking change here.

*Add {{static JSONArray empty()}}*
Similar to {{{}Collections.emptyList(){}}}, a convenience method for creating 
an empty and immutable instance should be added to reduce object creation / 
memory requirements, as an {{ArrayList}} will always needs some memory, even if 
empty.
Implementation-wise, it would require a new (private) constructor that allows 
setting the underlying data structure.
Then, {{empty()}} could simply use {{{}Collections.emptyList(){}}}.

{color:#FF0000}As the changes contain a breaking change, it should be released 
in a minor-release, not patch.{color}

Related mailing list thread: 
[https://lists.apache.org/thread/pf7hwy2tp5x7ktbzq9w2btwdd1xkyod2]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to