{"action":"created","comment":{"url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/comments/49792410","id":49792410,"diff_hunk":"@@ -93,69 +102,80 @@ +(void)saveModels:(NSArray *)models toFolder:(NSURL *)url\n     }];\n }\n \n++ (NSString *)stringForLanguage:(RLMModelExporterLanguage)language\n+{\n+    switch (language) {\n+        case RLMModelExporterLanguageJava: return @\"Java\";\n+        case RLMModelExporterLanguageObjectiveC: return @\"Objective-C\";\n+        case RLMModelExporterLanguageSwift: return @\"Swift\";\n+    }\n+}\n+\n+\n #pragma mark - Private methods - Java helpers\n \n-+(NSArray *)javaModelsOfSchemas:(NSArray *)schemas\n++ (NSArray *)javaModelsOfSchemas:(NSArray *)schemas\n {\n-    NSMutableArray *models = [NSMutableArray array];\n-    \n+    NSMutableArray *models = [NSMutableArray arrayWithCapacity:schemas.count];\n+\n     for (RLMObjectSchema *schema in schemas) {\n-        NSString *fileName = [schema.className stringByAppendingPathExtension:@\"java\"];\n-        \n-        NSMutableString *model = [NSMutableString string];\n-        [model appendFormat:@\"package your.package.name.here;\\n\\nimport io.realm.RealmObject;\\n\"];\n+        NSMutableString *model = [NSMutableString stringWithString:@\"package your.package.name.here;\\n\\nimport io.realm.RealmObject;\\n\"];\n \n-        bool importedRealmList = false;\n+        BOOL importedRealmList = YES;\n         NSMutableArray *importedRealmObjects = [[NSMutableArray alloc] init];\n         for (RLMProperty *property in schema.properties) {\n             if (property.type == RLMPropertyTypeArray) {\n                 if (!importedRealmList) {\n                     [model appendFormat:@\"import io.realm.RealmList;\\n\"];\n-                    importedRealmList = true;\n+                    importedRealmList = YES;\n                 }\n                 if (![importedRealmObjects containsObject:property.objectClassName]) {\n                     [model appendFormat:@\"import %@;\\n\", property.objectClassName];\n                     [importedRealmObjects addObject:property.objectClassName];\n                 }\n-            }\n-            if (property.type == RLMPropertyTypeObject) {\n-                if (![importedRealmObjects containsObject:property.objectClassName]) {\n-                    [model appendFormat:@\"import %@;\\n\", property.objectClassName];\n-                    [importedRealmObjects addObject:property.objectClassName];\n-                }\n+            } else if (property.type == RLMPropertyTypeObject && ![importedRealmObjects containsObject:property.objectClassName]) {\n+                [model appendFormat:@\"import %@;\\n\", property.objectClassName];\n+                [importedRealmObjects addObject:property.objectClassName];\n             }\n         }\n-        [model appendFormat:@\"\\n\"];\n \n-        [model appendFormat:@\"public class %@ extends RealmObject {\\n\", schema.className];\n+        [model appendFormat:@\"\\npublic class %@ extends RealmObject {\\n\", schema.className];\n \n         // fields\n         for (RLMProperty *property in schema.properties) {\n+            if (property.isPrimary) {\n+                [model appendString:@\"    @PrimaryKey\\n\"];","path":"RealmBrowser/Classes/RLMModelExporter.m","position":158,"original_position":158,"commit_id":"598c30a51e28032ae7e78725c9e6c39ad701ce0d","original_commit_id":"598c30a51e28032ae7e78725c9e6c39ad701ce0d","user":{"login":"cmelchior","id":406066,"avatar_url":"https://avatars.githubusercontent.com/u/406066?v=3","gravatar_id":"","url":"https://api.github.com/users/cmelchior","html_url":"https://github.com/cmelchior","followers_url":"https://api.github.com/users/cmelchior/followers","following_url":"https://api.github.com/users/cmelchior/following{/other_user}","gists_url":"https://api.github.com/users/cmelchior/gists{/gist_id}","starred_url":"https://api.github.com/users/cmelchior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmelchior/subscriptions","organizations_url":"https://api.github.com/users/cmelchior/orgs","repos_url":"https://api.github.com/users/cmelchior/repos","events_url":"https://api.github.com/users/cmelchior/events{/privacy}","received_events_url":"https://api.github.com/users/cmelchior/received_events","type":"User","site_admin":false},"body":"Yes that is fine.  Any order will work, but most IDE's does it alphabetically. ","created_at":"2016-01-14T22:04:09Z","updated_at":"2016-01-14T22:04:09Z","html_url":"https://github.com/realm/realm-browser-osx/pull/122#discussion_r49792410","pull_request_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122","_links":{"self":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/comments/49792410"},"html":{"href":"https://github.com/realm/realm-browser-osx/pull/122#discussion_r49792410"},"pull_request":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122"}}},"pull_request":{"url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122","id":56091146,"html_url":"https://github.com/realm/realm-browser-osx/pull/122","diff_url":"https://github.com/realm/realm-browser-osx/pull/122.diff","patch_url":"https://github.com/realm/realm-browser-osx/pull/122.patch","issue_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/122","number":122,"state":"open","locked":false,"title":"Improve Java model generation","user":{"login":"jpsim","id":474794,"avatar_url":"https://avatars.githubusercontent.com/u/474794?v=3","gravatar_id":"","url":"https://api.github.com/users/jpsim","html_url":"https://github.com/jpsim","followers_url":"https://api.github.com/users/jpsim/followers","following_url":"https://api.github.com/users/jpsim/following{/other_user}","gists_url":"https://api.github.com/users/jpsim/gists{/gist_id}","starred_url":"https://api.github.com/users/jpsim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpsim/subscriptions","organizations_url":"https://api.github.com/users/jpsim/orgs","repos_url":"https://api.github.com/users/jpsim/repos","events_url":"https://api.github.com/users/jpsim/events{/privacy}","received_events_url":"https://api.github.com/users/jpsim/received_events","type":"User","site_admin":false},"body":"This PR aims to update Java model generation to handle primary, indexed & required fields. Note that I have absolutely no idea what I'm doing here, so I'll need someone from Realm Java to let me know if this is ok, or more likely what I need to fix.\r\n\r\nDepends on #120. See https://github.com/realm/realm-browser-osx/compare/jp-generate-swift-models...jp-improve-java-model-generation for just the changes in this PR.\r\n\r\n/cc @kneth @cmelchior @TimOliver","created_at":"2016-01-14T20:45:50Z","updated_at":"2016-01-14T22:04:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5bac4550bb2e5fc9c0479bf7b08c656fe624008c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122/commits","review_comments_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122/comments","review_comment_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/122/comments","statuses_url":"https://api.github.com/repos/realm/realm-browser-osx/statuses/598c30a51e28032ae7e78725c9e6c39ad701ce0d","head":{"label":"realm:jp-improve-java-model-generation","ref":"jp-improve-java-model-generation","sha":"598c30a51e28032ae7e78725c9e6c39ad701ce0d","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":36412959,"name":"realm-browser-osx","full_name":"realm/realm-browser-osx","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-browser-osx","description":"Realm Browser is a Mac OS X utility to open and modify realm database files.","fork":false,"url":"https://api.github.com/repos/realm/realm-browser-osx","forks_url":"https://api.github.com/repos/realm/realm-browser-osx/forks","keys_url":"https://api.github.com/repos/realm/realm-browser-osx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-browser-osx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-browser-osx/teams","hooks_url":"https://api.github.com/repos/realm/realm-browser-osx/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-browser-osx/events","assignees_url":"https://api.github.com/repos/realm/realm-browser-osx/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-browser-osx/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-browser-osx/tags","blobs_url":"https://api.github.com/repos/realm/realm-browser-osx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-browser-osx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-browser-osx/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-browser-osx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-browser-osx/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-browser-osx/languages","stargazers_url":"https://api.github.com/repos/realm/realm-browser-osx/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-browser-osx/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-browser-osx/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-browser-osx/subscription","commits_url":"https://api.github.com/repos/realm/realm-browser-osx/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-browser-osx/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-browser-osx/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/comments{/number}","contents_url":"https://api.github.com/repos/realm/realm-browser-osx/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-browser-osx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-browser-osx/merges","archive_url":"https://api.github.com/repos/realm/realm-browser-osx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-browser-osx/downloads","issues_url":"https://api.github.com/repos/realm/realm-browser-osx/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-browser-osx/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-browser-osx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-browser-osx/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-browser-osx/releases{/id}","created_at":"2015-05-28T03:41:35Z","updated_at":"2016-01-14T17:01:55Z","pushed_at":"2016-01-14T20:45:50Z","git_url":"git://github.com/realm/realm-browser-osx.git","ssh_url":"git@github.com:realm/realm-browser-osx.git","clone_url":"https://github.com/realm/realm-browser-osx.git","svn_url":"https://github.com/realm/realm-browser-osx","homepage":null,"size":16768,"stargazers_count":130,"watchers_count":130,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":34,"forks":10,"open_issues":34,"watchers":130,"default_branch":"master"}},"base":{"label":"realm:master","ref":"master","sha":"afea57dc6fa75bde76c31e51ae7fcf91a5c1cca9","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":36412959,"name":"realm-browser-osx","full_name":"realm/realm-browser-osx","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-browser-osx","description":"Realm Browser is a Mac OS X utility to open and modify realm database files.","fork":false,"url":"https://api.github.com/repos/realm/realm-browser-osx","forks_url":"https://api.github.com/repos/realm/realm-browser-osx/forks","keys_url":"https://api.github.com/repos/realm/realm-browser-osx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-browser-osx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-browser-osx/teams","hooks_url":"https://api.github.com/repos/realm/realm-browser-osx/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-browser-osx/events","assignees_url":"https://api.github.com/repos/realm/realm-browser-osx/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-browser-osx/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-browser-osx/tags","blobs_url":"https://api.github.com/repos/realm/realm-browser-osx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-browser-osx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-browser-osx/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-browser-osx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-browser-osx/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-browser-osx/languages","stargazers_url":"https://api.github.com/repos/realm/realm-browser-osx/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-browser-osx/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-browser-osx/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-browser-osx/subscription","commits_url":"https://api.github.com/repos/realm/realm-browser-osx/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-browser-osx/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-browser-osx/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-browser-osx/issues/comments{/number}","contents_url":"https://api.github.com/repos/realm/realm-browser-osx/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-browser-osx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-browser-osx/merges","archive_url":"https://api.github.com/repos/realm/realm-browser-osx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-browser-osx/downloads","issues_url":"https://api.github.com/repos/realm/realm-browser-osx/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-browser-osx/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-browser-osx/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-browser-osx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-browser-osx/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-browser-osx/releases{/id}","created_at":"2015-05-28T03:41:35Z","updated_at":"2016-01-14T17:01:55Z","pushed_at":"2016-01-14T20:45:50Z","git_url":"git://github.com/realm/realm-browser-osx.git","ssh_url":"git@github.com:realm/realm-browser-osx.git","clone_url":"https://github.com/realm/realm-browser-osx.git","svn_url":"https://github.com/realm/realm-browser-osx","homepage":null,"size":16768,"stargazers_count":130,"watchers_count":130,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":34,"forks":10,"open_issues":34,"watchers":130,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122"},"html":{"href":"https://github.com/realm/realm-browser-osx/pull/122"},"issue":{"href":"https://api.github.com/repos/realm/realm-browser-osx/issues/122"},"comments":{"href":"https://api.github.com/repos/realm/realm-browser-osx/issues/122/comments"},"review_comments":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122/comments"},"review_comment":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/realm/realm-browser-osx/pulls/122/commits"},"statuses":{"href":"https://api.github.com/repos/realm/realm-browser-osx/statuses/598c30a51e28032ae7e78725c9e6c39ad701ce0d"}}}}