{"id":1548,"date":"2017-09-03T17:25:56","date_gmt":"2017-09-03T09:25:56","guid":{"rendered":"http:\/\/coderbee.net\/?p=1548"},"modified":"2017-09-03T17:25:56","modified_gmt":"2017-09-03T09:25:56","slug":"java-util-collections-singleton","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/java\/20170903\/1548","title":{"rendered":"java.util.Collections.singleton*"},"content":{"rendered":"<p>\u4eca\u5929\u5728\u6284 <a href=\"https:\/\/github.com\/weibocom\/motan\">Motan<\/a> \u7684\u4ee3\u7801\u65f6\u624d\u53d1\u73b0 <code>java.util.Collections<\/code> \u6709\u4e09\u4e2a\u4ee5 singleton \u5f00\u5934\u7684\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\n<p><code>public static &lt;T&gt; List&lt;T&gt; singletonList(T o)<\/code>\uff1a\u8fd4\u56de\u4e00\u4e2a\u5185\u90e8\u7c7b <code>SingletonList<\/code> \u7684\u5b9e\u4f8b\u3002<\/p>\n<\/li>\n<li>\n<p><code>public static &lt;T&gt; Set&lt;T&gt; singleton(T o)<\/code>\uff1a\u8fd4\u56de\u4e00\u4e2a\u5185\u90e8\u7c7b <code>SingletonSet<\/code> \u7684\u5b9e\u4f8b\u3002<\/p>\n<\/li>\n<li>\n<p><code>public static &lt;K,V&gt; Map&lt;K,V&gt; singletonMap(K key, V value)<\/code>\uff1a\u8fd4\u56de\u4e00\u4e2a\u5185\u90e8\u7c7b <code>SingletonMap<\/code> \u7684\u5b9e\u4f8b\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e09\u4e2a\u5185\u90e8\u7c7b\u90fd\u662f\u975e\u5e38\u9ad8\u6548\u7684\uff1a<br \/>\n* <code>SingletonList<\/code> \u548c <code>SingletonSet<\/code> \u90fd\u7528\u4e00\u4e2a\u5c5e\u6027\u6765\u8868\u793a\u62e5\u6709\u7684\u5143\u7d20\uff0c\u800c\u4e0d\u662f\u7528\u6570\u7ec4\u3001\u5217\u8868\u6765\u8868\u793a\uff1b<code>SingletonMap<\/code> \u5206\u522b\u7528\u4e24\u4e2a\u5c5e\u6027\u8868\u793a key\/value\uff1b\u5185\u5b58\u4f7f\u7528\u4e0a\u66f4\u9ad8\u6548\uff1b<br \/>\n* \u5728\u65b9\u6cd5\u7684\u5b9e\u73b0\u4e0a\u4e5f\u66f4\u9ad8\u6548\uff0c\u51cf\u5c11\u4e86\u5faa\u73af\u3002\u6bd4\u5982 <code>size<\/code> \u65b9\u6cd5\u90fd\u662f\u76f4\u63a5\u8fd4\u56de 1 \uff1b<code>List.contains<\/code> \u65b9\u6cd5\u662f\u628a\u53c2\u6570\u4e0e\u5c5e\u6027\u5143\u7d20\u76f4\u63a5\u5bf9\u6bd4\u3002<\/p>\n<p>\u771f\u662f\u4e00\u79cd\u8ffd\u6c42\u6027\u80fd\u6781\u9650\u7684\u7cbe\u795e\uff01\u6211\u4eec\u8981\u5145\u5206\u5229\u7528\u597d\u8fd9\u4e9b\u7279\u6027\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5728\u6284 Motan \u7684\u4ee3\u7801\u65f6\u624d\u53d1\u73b0 java.util.Collections &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/java\/20170903\/1548\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[286],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1548"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1548"}],"version-history":[{"count":3,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1548\/revisions"}],"predecessor-version":[{"id":1551,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1548\/revisions\/1551"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}