[
https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444743#comment-16444743
]
Jezza edited comment on WICKET-6550 at 4/19/18 8:31 PM:
--------------------------------------------------------
In the commit message, I said it could be extended.
Something like this could be add to the interface, among others.
{code:java}
default <T extends B> T computeMetadataIfAbsent(MetaDataKey<T> key, Supplier<T>
supplier) {
T data = getMetaData(key);
if (data == null) {
data = supplier.get();
setMetaData(key, data);
}
return data;
}
{code}
was (Author: jezza):
In the commit message, I said it could be extended.
Something like this could be add to the interface, among others.
{code:java}
default <T extends B> T computeMetadataIfAbsent(MetaDataKey<T> key, Supplier<T>
supplier) {
T data = getMetaData(key);
if (data == null) {
data = supplier.get();
setMetaData(key, data);
}
return data;
}
{code}
> Unify all metadata capable objects.
> -----------------------------------
>
> Key: WICKET-6550
> URL: https://issues.apache.org/jira/browse/WICKET-6550
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Reporter: Jezza
> Priority: Minor
> Attachments: Test.java, mock.txt
>
>
> Application, Session, RequestCycle, and Component all have #setMetadata and
> #getMetadata methods, but lack some super object to unify them all.
> These leads to annoying complex code if you wish to implement some basic
> functionality.
> Such as a computeIfAbsent, which needs to be implemented 4 times.
> I propose that we unify them all with one interface.
> I've attached a mock idea that would solve it, and I'll work on a prototype
> and submit a PR so anyone can take a look.
> I'll add a comment here with the PR number.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)