TIP: Declaration and initialization of an unmodifiable static final Set

    static final Set<String> stringSet =
            Collections.unmodifiableSet(
                new HashSet<String>(Arrays.asList(
                    "foo",
                    "bar",
                    "baz"
                    )));

Modified based on a tip by Rafael de F. Ferreira. I cannot use a trailing comma on each line though for easy addition/removal of entries.

Comments:

Sad, I must say. Looks like I nice tree on the other side, if you go further away from the screen :)

Posted by Thomas Zillinger on June 05, 2007 at 08:10 PM PDT #

I just filed a bug about not being able to add a property to the Session Bean via the right-click menu. http://www.netbeans.org/issues/show_bug.cgi?id=106148 This functionality was available in 5.5, but I am told this will not be fixed for 6.0. Why are regression bugs not being considered for the 6.0 release? Your name was on a related bug, and I do not know who else to address this with.

Posted by John Parker on June 11, 2007 at 01:38 AM PDT #

John, Thanks for your feedback.

In fact during 6.0 development the infrastructure for Java language was changed from JMI/MDR based to Retouche/Javac based. As a result a lot of regressions appeared and then were addressed. I thought this feature was one such feature and thought it will come back. I was surprised to find out that will not be the case. I will let the developers know. You can send an email on nbdev@netbeans.org.

Sorry this is not very satisfactory.

Posted by Sandip on June 11, 2007 at 02:44 AM PDT #

Java 5 improves it somewhat:

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableSet;

...

static final Set<String> stringSet =
___unmodifiableSet(
______new HashSet<String>(
_________asList("foo", "bar", "baz")));

Posted by Rafael de F. Ferreira on October 24, 2007 at 06:33 AM PDT #

varargs of course. I had missed that. Thanks.

Posted by Sandip on October 24, 2007 at 06:56 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

sandipchitale

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today