java - Ways to signal that API returns an unmodifiable/immutable collection -


other documenting (obviously should documented), using special return type (i'm wary of limiting myself immutablex) or having user find out @ runtime, there other way of telling users of api collection receive said api unmodifiable/immutable?

are there naming conventions or marker annotations universally signal same thing?

edit: unmodifiable , immutable not mean same thing, purposes of question, similar enough. question boils down letting user know returned object not honour contract (ie. common operations throw runtime exception).

not general naming convention might interested in using @immutable annotation: http://aspects.jcabi.com/annotation-immutable.html besides documentation purpose mechanism validate if object immutable (during it's instantiation) , throw runtime exception if not.


Comments