<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:31 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-2554] Investigate Optional support for the Pojo Codec</title>
                <link>https://jira.mongodb.org/browse/JAVA-2554</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;PR: &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/418&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/418&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="403930">JAVA-2554</key>
            <summary>Investigate Optional support for the Pojo Codec</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="ross@mongodb.com">Ross Lawley</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 Jul 2017 09:04:46 +0000</created>
                <updated>Sun, 29 Oct 2023 02:32:40 +0000</updated>
                            <resolved>Mon, 4 Dec 2017 09:57:03 +0000</resolved>
                                                    <fixVersion>3.6.0</fixVersion>
                                    <component>POJO</component>
                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1742109" author="xgen-internal-githook" created="Mon, 4 Dec 2017 20:41:42 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jflorencio&apos;, &apos;email&apos;: &apos;joe@deal.com&apos;, &apos;name&apos;: &apos;Joseph Florencio&apos;}
&lt;p&gt;Message: Support for custom container types&lt;/p&gt;

&lt;p&gt;While PojoCodec accounts for generic containers, it only&lt;br/&gt;
accounts for it when the PojoCodec is the one that encodes&lt;br/&gt;
and decodes it.&lt;/p&gt;

&lt;p&gt;This doesn&apos;t work if you want to use Java 8 Optionals, or&lt;br/&gt;
other containers classes you don&apos;t have source code access to,&lt;br/&gt;
and can&apos;t be automatically serialized/deserialized.&lt;/p&gt;

&lt;p&gt;To make this possible I introduced 4 changes to the public API:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;`TypeWithTypeParameters`: This is an interface that `TypeData` now&lt;br/&gt;
  implements that exposes the captured type parameter data. The intention&lt;br/&gt;
  here was to reduce the surface area of the API exposed since TypeData&lt;br/&gt;
  has quite a bit going on, and I don&apos;t think we want to commit to such&lt;br/&gt;
  an API.&lt;/li&gt;
	&lt;li&gt;`PropertyCodecRegistry`: This is a new interface that&apos;s analogous to&lt;br/&gt;
  `CodecRegistry`, except instead of accepting a `Class&amp;lt;T&amp;gt;`, it accepts&lt;br/&gt;
  a `TypeWithTypeParameters&amp;lt;T&amp;gt;`. This is strictly for consumption by&lt;br/&gt;
  clients of the API - there is no expectation clients would implement&lt;br/&gt;
  it since it&apos;s provided through the property codec provider.&lt;/li&gt;
	&lt;li&gt;`PropertyCodecProvider`: Similar to above, this is anologous to&lt;br/&gt;
  `CodecProvider` except that it accepts a `TypeWithTypeParameters&amp;lt;T&amp;gt;` and&lt;br/&gt;
  a `PropertyCodecRegistry`. This is the primary interface that&apos;s&lt;br/&gt;
  implemented to support implementing custom containers like collections,&lt;br/&gt;
  maps, options, etc.&lt;/li&gt;
	&lt;li&gt;`PojoCodecProvider.Builder#register(PropertyCodecProvider...)`:&lt;br/&gt;
  How clients register the providers. Note that they cannot register a&lt;br/&gt;
  registry - this isn&apos;t as permissive as codec providers so it&apos;s&lt;br/&gt;
  intentionally constrained here.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Internally I shifted the implementation of enums, maps and collections to use&lt;br/&gt;
this new setup as well. You can see `CollectionPropertyCodecProvider`&lt;br/&gt;
and `MapPropertyCodecProvider` for how this looks - they&apos;re just&lt;br/&gt;
implicitly added to the same registration list clients use (see&lt;br/&gt;
`PojoCodecImpl.PropertyCodecRegistryImpl`).&lt;/p&gt;

&lt;p&gt;In the tests I implemented `OptionalPropertyCodecProviderForTest` which&lt;br/&gt;
is a provider for a custom optional class, which gives an example for&lt;br/&gt;
people who would like to do the same, or support Java 8 optionals.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2554&quot; title=&quot;Investigate Optional support for the Pojo Codec&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2554&quot;&gt;&lt;del&gt;JAVA-2554&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 3.6.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/f525edfb09141b460b68ff7b974ae9099e0fa7fe&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/f525edfb09141b460b68ff7b974ae9099e0fa7fe&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1741275" author="ross@10gen.com" created="Mon, 4 Dec 2017 09:57:03 +0000"  >&lt;p&gt;A massive thank you to Joseph Florencio for the excellent pull request.&lt;/p&gt;</comment>
                            <comment id="1741260" author="xgen-internal-githook" created="Mon, 4 Dec 2017 09:39:06 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;jflorencio&apos;, &apos;email&apos;: &apos;joe@deal.com&apos;, &apos;name&apos;: &apos;Joseph Florencio&apos;}
&lt;p&gt;Message: Support for custom container types&lt;/p&gt;

&lt;p&gt;While PojoCodec accounts for generic containers, it only&lt;br/&gt;
accounts for it when the PojoCodec is the one that encodes&lt;br/&gt;
and decodes it.&lt;/p&gt;

&lt;p&gt;This doesn&apos;t work if you want to use Java 8 Optionals, or&lt;br/&gt;
other containers classes you don&apos;t have source code access to,&lt;br/&gt;
and can&apos;t be automatically serialized/deserialized.&lt;/p&gt;

&lt;p&gt;To make this possible I introduced 4 changes to the public API:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;`TypeWithTypeParameters`: This is an interface that `TypeData` now&lt;br/&gt;
  implements that exposes the captured type parameter data. The intention&lt;br/&gt;
  here was to reduce the surface area of the API exposed since TypeData&lt;br/&gt;
  has quite a bit going on, and I don&apos;t think we want to commit to such&lt;br/&gt;
  an API.&lt;/li&gt;
	&lt;li&gt;`PropertyCodecRegistry`: This is a new interface that&apos;s analogous to&lt;br/&gt;
  `CodecRegistry`, except instead of accepting a `Class&amp;lt;T&amp;gt;`, it accepts&lt;br/&gt;
  a `TypeWithTypeParameters&amp;lt;T&amp;gt;`. This is strictly for consumption by&lt;br/&gt;
  clients of the API - there is no expectation clients would implement&lt;br/&gt;
  it since it&apos;s provided through the property codec provider.&lt;/li&gt;
	&lt;li&gt;`PropertyCodecProvider`: Similar to above, this is anologous to&lt;br/&gt;
  `CodecProvider` except that it accepts a `TypeWithTypeParameters&amp;lt;T&amp;gt;` and&lt;br/&gt;
  a `PropertyCodecRegistry`. This is the primary interface that&apos;s&lt;br/&gt;
  implemented to support implementing custom containers like collections,&lt;br/&gt;
  maps, options, etc.&lt;/li&gt;
	&lt;li&gt;`PojoCodecProvider.Builder#register(PropertyCodecProvider...)`:&lt;br/&gt;
  How clients register the providers. Note that they cannot register a&lt;br/&gt;
  registry - this isn&apos;t as permissive as codec providers so it&apos;s&lt;br/&gt;
  intentionally constrained here.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Internally I shifted the implementation of enums, maps and collections to use&lt;br/&gt;
this new setup as well. You can see `CollectionPropertyCodecProvider`&lt;br/&gt;
and `MapPropertyCodecProvider` for how this looks - they&apos;re just&lt;br/&gt;
implicitly added to the same registration list clients use (see&lt;br/&gt;
`PojoCodecImpl.PropertyCodecRegistryImpl`).&lt;/p&gt;

&lt;p&gt;In the tests I implemented `OptionalPropertyCodecProviderForTest` which&lt;br/&gt;
is a provider for a custom optional class, which gives an example for&lt;br/&gt;
people who would like to do the same, or support Java 8 optionals.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2554&quot; title=&quot;Investigate Optional support for the Pojo Codec&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2554&quot;&gt;&lt;del&gt;JAVA-2554&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/f525edfb09141b460b68ff7b974ae9099e0fa7fe&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/f525edfb09141b460b68ff7b974ae9099e0fa7fe&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2328436">JAVA-4954</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrar3z:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>