{"action":"created","issue":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/751","repository_url":"https://api.github.com/repos/mapstruct/mapstruct","labels_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/751/labels{/name}","comments_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/751/comments","events_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/751/events","html_url":"https://github.com/mapstruct/mapstruct/issues/751","id":133197731,"number":751,"title":"Get access to mapper instance","user":{"login":"sjaakd","id":6173283,"avatar_url":"https://avatars.githubusercontent.com/u/6173283?v=3","gravatar_id":"","url":"https://api.github.com/users/sjaakd","html_url":"https://github.com/sjaakd","followers_url":"https://api.github.com/users/sjaakd/followers","following_url":"https://api.github.com/users/sjaakd/following{/other_user}","gists_url":"https://api.github.com/users/sjaakd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjaakd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjaakd/subscriptions","organizations_url":"https://api.github.com/users/sjaakd/orgs","repos_url":"https://api.github.com/users/sjaakd/repos","events_url":"https://api.github.com/users/sjaakd/events{/privacy}","received_events_url":"https://api.github.com/users/sjaakd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapstruct/mapstruct/labels/feature","name":"feature","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2016-02-12T09:50:02Z","updated_at":"2016-06-15T18:23:15Z","closed_at":null,"body":"I keep on finding cases were I need access to a used mapper instance (abstract class).\r\n\r\nCases I came up with so far: \r\n1. Inserting sequence numbers.\r\n2. Reuse of common base mapper (were you need an instance variable on the mapper distinguising between behaviors).\r\n\r\nThe only way to do this  (in the standard component model) is `ThreadLocals`. \r\n\r\nFor scenario 1. It woudl be nice if the generated mapper generates standard getters on its instance variables when a getter is present in the `@Mapper` interface / abstract class with a used mapper as return type.\r\n\r\nFor scenario 2. It could help if a used mapper is constructed by factory as well (not only target objects).\r\n\r\nSee also http://g00glen00b.be/mapstruct/\r\n"},"comment":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/comments/226275803","html_url":"https://github.com/mapstruct/mapstruct/issues/751#issuecomment-226275803","issue_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/751","id":226275803,"user":{"login":"sjaakd","id":6173283,"avatar_url":"https://avatars.githubusercontent.com/u/6173283?v=3","gravatar_id":"","url":"https://api.github.com/users/sjaakd","html_url":"https://github.com/sjaakd","followers_url":"https://api.github.com/users/sjaakd/followers","following_url":"https://api.github.com/users/sjaakd/following{/other_user}","gists_url":"https://api.github.com/users/sjaakd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjaakd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjaakd/subscriptions","organizations_url":"https://api.github.com/users/sjaakd/orgs","repos_url":"https://api.github.com/users/sjaakd/repos","events_url":"https://api.github.com/users/sjaakd/events{/privacy}","received_events_url":"https://api.github.com/users/sjaakd/received_events","type":"User","site_admin":false},"created_at":"2016-06-15T18:23:15Z","updated_at":"2016-06-15T18:23:15Z","body":"> Did you pursue that idea any further, @sjaakd? I feel it may actually resolve some of the issues we discussed. WDYT?\r\n\r\nNo. I spent quite some time on the current solution 😭.  I'm personally not in favor of 'dragging' a parameter through many method calls (e.g. in an object graph) to the spot where you need it, especially if this parameter 'defines' the behavior of en entire mapper, like the examples provided.\r\n\r\nAlso, you mentioned the singleton pattern that we advocate. However, we do sin ourselves :smile: in the code we generate, were we call `Mapperers.getMapper`.. \r\n\r\nIf we (really) can't find an agreement on how to continue on this one, we should investigate if there are salvageable parts. E.g. the introduced mapper factory concept.\r\n"}}
{"actor":{"display_login":"sjaakd"}}