[ 
https://issues.apache.org/jira/browse/AVRO-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828679#action_12828679
 ] 

Scott Carey commented on AVRO-261:
----------------------------------

Another read-only design pattern is a bit unusual but perhaps performs better 
than the wrapper:

A parent class is mutable, and its child class is immutable. package protected 
methods can pass around the mutable version, and cast freely between them.

Essentially, create 'ImmutableArrayList extends ArrayList' as the return type 
of the getters.  A user _could_ cast up to ArrayList and set it, but that would 
break the contract and wouldn't happen by accident.
If ImmutableArrayList isn't passed in when set, the mutable List passed in 
would have to be copied to an ImmutableArrayList.

If most of the methods inside these classes operates on ImmutableArrayList 
directly instead of the List interface, performance may also go up a little. 
However, use of this concrete class internally needs to be carefully 
coordinated with the public API.



> Allow Schemas to be immutable
> -----------------------------
>
>                 Key: AVRO-261
>                 URL: https://issues.apache.org/jira/browse/AVRO-261
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Kevin Oliver
>            Assignee: Thiruvalluvan M. G.
>            Priority: Minor
>         Attachments: AVRO-261.patch
>
>
> It would be nice if there was the ability to have an immutable Schema in 
> java. 
> Without this, it makes sharing schemas risky. Also, with this, we could 
> (lazily) cache the hashCode which is a fairly expensive operation today, 
> especially on something like a record.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to