GitHub PullRequestReviewCommentEvent at 2014-02-06 17:07:09
Repository: junit
Actor: kcooney
Payload: {"comment":{"url":"https://api.github.com/repos/junit-team/junit/pulls/comments/9508384","id":9508384,"diff_hunk":"@@ -0,0 +1,111 @@\n+package org.junit.runner;\n+\n+import java.lang.annotation.Annotation;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+/**\n+ * This <code>DescriptionBuilder</code> implements the builder pattern for the\n+ * <code>Description</code> class. You can use it to easily create new\n+ * descriptions without knowing about the detailed implementation of the\n+ * <code>Description</code> class.\n+ *\n+ * @see org.junit.runner.Description\n+ * @since 4.12\n+ */\n+public class DescriptionBuilder {\n+\tprivate static final Annotation[] TYPE = new Annotation[0];\n+\n+\tprivate final Class<?> testClass;\n+\n+\tprivate String displayName;\n+\tprivate String uniqueId;\n+\tprivate List<Annotation> annotations;\n+\n+\t/**\n+\t * Create a <code>DescriptionBuilder</code> for <code>testClass</code>.\n+\t * Additional attribute may be added to the builder before the\n+\t * <code>Description</code> is finally built using the build() method.\n+\t *\n+\t * @param testClass A {@link Class} containing tests\n+\t * @return a <code>DescriptionBuilder</code> for <code>testClass</code>\n+\t */\n+\tpublic static DescriptionBuilder forClass(final Class<?> testClass) {\n+\t\treturn new DescriptionBuilder(testClass);\n+\t}\n+\n+\tprivate DescriptionBuilder(final Class<?> testClass) {\n+\t\tthis.testClass = testClass;\n+\t\tthis.displayName = testClass.getSimpleName();\n+\t\tthis.uniqueId = testClass.getCanonicalName();\n+\t\tthis.annotations = Arrays.asList(testClass.getAnnotations());\n+\t}\n+\n+\t/**\n+\t * Changes the display name to the given value.\n+\t *\n+\t * @param displayName the new display name\n+\t */\n+\tpublic void withDisplayName(final String displayName) {\n+\t\tthis.displayName = displayName;\n+\t}\n+\n+\t/**\n+\t * Changes the unique ID to the given value.\n+\t *\n+\t * @param uniqueId the new unique ID\n+\t */\n+\tpublic void withUniqueId(final String uniqueId) {\n+\t\tthis.uniqueId = uniqueId;\n+\t}\n+\n+\t/**\n+\t * Adds additional annotations. These annotations are passed to the\n+\t * <code>Description</code> for downstream interpreters.\n+\t *\n+\t * @param annotations the additional annotations\n+\t */\n+\tpublic void withAdditionalAnnotations(final List<Annotation> annotations) {\n+\t\tif (annotations != null)","path":"src/main/java/org/junit/runner/DescriptionBuilder.java","position":70,"original_position":70,"commit_id":"7bb16080f43d101c4e5e229582b4aa821fd4f1e4","original_commit_id":"7bb16080f43d101c4e5e229582b4aa821fd4f1e4","user":{"login":"kcooney","id":478190,"avatar_url":"https://gravatar.com/avatar/3e1323e035210af33f94c2d19192c936?d=https%3A%2F%2Fidenticons.github.com%2Fd9f3ec9920b2824b1faaca137adf3c9a.png&r=x","gravatar_id":"3e1323e035210af33f94c2d19192c936","url":"https://api.github.com/users/kcooney","html_url":"https://github.com/kcooney","followers_url":"https://api.github.com/users/kcooney/followers","following_url":"https://api.github.com/users/kcooney/following{/other_user}","gists_url":"https://api.github.com/users/kcooney/gists{/gist_id}","starred_url":"https://api.github.com/users/kcooney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcooney/subscriptions","organizations_url":"https://api.github.com/users/kcooney/orgs","repos_url":"https://api.github.com/users/kcooney/repos","events_url":"https://api.github.com/users/kcooney/events{/privacy}","received_events_url":"https://api.github.com/users/kcooney/received_events","type":"User","site_admin":false},"body":"I don't think we should silently ignore nulls. There's a detailed discussion in Effective Java, Second Edition, Item 38 and Item 60.\r\n\r\nI believe addAll() will throw a NullPointerException if you pass in a null. If not, we should do this IMHO:\r\n\r\n    if (annotations == null) {\r\n        throw new NullPointerException(\"annotations is null\");\r\n    }\r\n","created_at":"2014-02-06T17:07:09Z","updated_at":"2014-02-06T17:07:09Z","html_url":"https://github.com/junit-team/junit/pull/814#discussion_r9508384","pull_request_url":"https://api.github.com/repos/junit-team/junit/pulls/814","_links":{"self":{"href":"https://api.github.com/repos/junit-team/junit/pulls/comments/9508384"},"html":{"href":"https://github.com/junit-team/junit/pull/814#discussion_r9508384"},"pull_request":{"href":"https://api.github.com/repos/junit-team/junit/pulls/814"}}}}