[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444727#comment-16444727 ] ASF GitHub Bot commented on WICKET-6550: GitHub user Jezza opened a pull request: https://github.com/apache/wicket/pull/276 WICKET-6550 : Unify all metadata capable objects. Introduce a IMetadataContext that contains the current metadata implementation. This should allow more generic code to be written for all of the objects currently capable of storing and handling metadata. Ideally, this could be expanded with useful default methods. You can merge this pull request into a Git repository by running: $ git pull https://github.com/Jezza/wicket WICKET-6550 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/wicket/pull/276.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #276 commit e92bffdf596bdf96d88de3bb2fe64616a390719b Author: Jezza Date: 2018-04-19T20:16:47Z WICKET-6550 : Unify all metadata capable objects. Introduce a IMetadataContext that contains the current metadata implementation. This should allow more generic code to be written for all of the objects currently capable of storing and handling metadata. Ideally, this could be expanded with useful default methods. > 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: 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444728#comment-16444728 ] Jezza commented on WICKET-6550: --- [https://github.com/apache/wicket/pull/276] [^Test.java] shows what is now possible. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444743#comment-16444743 ] Jezza commented on WICKET-6550: --- 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 computeMetadataIfAbsent(MetaDataKey key, Supplier 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444746#comment-16444746 ] Jezza commented on WICKET-6550: --- Or if that isn't the direction we want to go in, the current state still lets us do something like: {code:java} public static T computeIfAbsent(IMetadataContext context, MetaDataKey key, Supplier supplier) { T data = context.getMetaData(key); if (data == null) { data = supplier.get(); context.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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444748#comment-16444748 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182876140 --- Diff: wicket-core/src/main/java/org/apache/wicket/IMetadataContext.java --- @@ -0,0 +1,10 @@ +package org.apache.wicket; + +/** + * @author Jezza + */ +public interface IMetadataContext { --- End diff -- I don't like the names of the generics, nor the R parameter. It was only added because the current implementation returns the object the method is enclosed in, so right now, it just conveys that type information. Ideally, I would want to remove it. One solution would be just to return the IMetadataContext itself, but you wouldn't be able to do much with the return result, short of just setting more metadata. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444750#comment-16444750 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182876774 --- Diff: wicket-core/src/main/java/org/apache/wicket/Application.java --- @@ -518,9 +519,13 @@ public void logResponseTarget(final IRequestHandler requestTarget) * @throws IllegalArgumentException * @see MetaDataKey */ - public final synchronized Application setMetaData(final MetaDataKey key, final Object object) + @Override + public final Application setMetaData(final MetaDataKey key, final T object) --- End diff -- I had to change the signature of this method. Ideally, it should have been that way anyway. Everything still compiles, which means we weren't putting values in keys that weren't expecting the value. I fear that some users might be doing exactly that though, so this whole IMetadataContext might have to be put off for a bigger version. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445402#comment-16445402 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182962256 --- Diff: wicket-core/src/main/java/org/apache/wicket/IMetadataContext.java --- @@ -0,0 +1,10 @@ +package org.apache.wicket; + +/** + * @author Jezza + */ +public interface IMetadataContext { --- End diff -- I also have doubts about the interface name. If anyone has a better suggestion, I'd be happy to swap it out. > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445419#comment-16445419 ] ASF GitHub Bot commented on WICKET-6550: Github user martin-g commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182965271 --- Diff: wicket-core/src/main/java/org/apache/wicket/Session.java --- @@ -422,6 +422,7 @@ public Locale getLocale() * @return The metadata * @see MetaDataKey */ + @Override public synchronized final M getMetaData(final MetaDataKey key) --- End diff -- Why in Application you moved `synchronized` in the method body and here it stays as before ? Is there any difference between the implementations ? > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445418#comment-16445418 ] ASF GitHub Bot commented on WICKET-6550: Github user martin-g commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182965042 --- Diff: wicket-core/src/main/java/org/apache/wicket/IMetadataContext.java --- @@ -0,0 +1,10 @@ +package org.apache.wicket; + +/** + * @author Jezza + */ +public interface IMetadataContext { --- End diff -- Javadoc would be nice! > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445439#comment-16445439 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182967962 --- Diff: wicket-core/src/main/java/org/apache/wicket/Session.java --- @@ -422,6 +422,7 @@ public Locale getLocale() * @return The metadata * @see MetaDataKey */ + @Override public synchronized final M getMetaData(final MetaDataKey key) --- End diff -- There's no practical difference with implementation, but I had to move it because it was clashing with the signature from the interface. > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445445#comment-16445445 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on a diff in the pull request: https://github.com/apache/wicket/pull/276#discussion_r182968690 --- Diff: wicket-core/src/main/java/org/apache/wicket/Session.java --- @@ -422,6 +422,7 @@ public Locale getLocale() * @return The metadata * @see MetaDataKey */ + @Override public synchronized final M getMetaData(final MetaDataKey key) --- End diff -- Ah, got it. Yeah, stupid mistake. I think initially I mistook the error for the sync modifier, but it was the `T object` parameter. Reverted that weird change. > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445447#comment-16445447 ] ASF GitHub Bot commented on WICKET-6550: Github user martin-g commented on the issue: https://github.com/apache/wicket/pull/276 Cool! Please just add Javadoc about the `tparam`s of IMetadataContext! LGTM! > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445449#comment-16445449 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on the issue: https://github.com/apache/wicket/pull/276 Added some javadoc with some barebones explanation. > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445588#comment-16445588 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on the issue: https://github.com/apache/wicket/pull/276 I just realised I should probably do `IMetadataContext>` > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445595#comment-16445595 ] ASF GitHub Bot commented on WICKET-6550: Github user Jezza commented on the issue: https://github.com/apache/wicket/pull/276 I went ahead and changed it. > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628430#comment-16628430 ] ASF GitHub Bot commented on WICKET-6550: Github user asfgit closed the pull request at: https://github.com/apache/wicket/pull/276 > 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 > Fix For: 9.0.0 > > 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 extra > functionality. > 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)
[jira] [Commented] (WICKET-6550) Unify all metadata capable objects.
[ https://issues.apache.org/jira/browse/WICKET-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628429#comment-16628429 ] ASF subversion and git services commented on WICKET-6550: - Commit 752b7a87c98be3c774c43fc1fbf8f60ce82f14ef in wicket's branch refs/heads/master from [~Jezza] [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=752b7a8 ] WICKET-6550 : Unify all metadata capable objects. Introduce a IMetadataContext that contains the current metadata implementation. This should allow more generic code to be written for all of the objects currently capable of storing and handling metadata. Ideally, this could be expanded with useful default methods. This closes #276 > 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 > Fix For: 9.0.0 > > 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 extra > functionality. > 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)