diff -r a00fba8d5136 api.annotations.common/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/build.xml Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,68 @@ + + + Builds, tests, and runs the project org.netbeans.annotations.common + + + + + Building common annotations for usage with FindBugs... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r a00fba8d5136 api.annotations.common/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/manifest.mf Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.api.annotations.common/1 +OpenIDE-Module-Localizing-Bundle: org/netbeans/annotations/common/resources/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r a00fba8d5136 api.annotations.common/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/nbproject/project.properties Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,41 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. + +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r a00fba8d5136 api.annotations.common/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/nbproject/project.xml Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,13 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.api.annotations.common + + + org.netbeans.api.annotations.common + + + + diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/annotations/common/resources/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/annotations/common/resources/Bundle.properties Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Common Annotations diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/api/annotations/common/CheckForNull.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/api/annotations/common/CheckForNull.java Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,60 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.api.annotations.common; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The annotated element might be null, thus code using it + * should check for nullity. + * + * @author Petr Hejl + */ +@Documented +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, + ElementType.LOCAL_VARIABLE}) +@Retention(RetentionPolicy.SOURCE) +public @interface CheckForNull { + +} diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/api/annotations/common/CheckReturnValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/api/annotations/common/CheckReturnValue.java Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.api.annotations.common; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The return value of annotated element (method) should be checked. Consider + * {@link java.io.File#delete()} as an example of such a method. + * + * @author Petr Hejl + */ +@Documented +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +public @interface CheckReturnValue { + +} diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/api/annotations/common/NonNull.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/api/annotations/common/NonNull.java Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.api.annotations.common; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The annotated element must not be null. + * + * @author Petr Hejl + */ +@Documented +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, + ElementType.LOCAL_VARIABLE}) +@Retention(RetentionPolicy.SOURCE) +public @interface NonNull { + +} diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/api/annotations/common/Nullable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/api/annotations/common/Nullable.java Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,63 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.api.annotations.common; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The annotated element might be null under certain circumstances. + * The necessity of the non-null check depends on situations described + * in the javadoc (so the non-null check is not required by default). + * + * @author Andrei Badea + */ +@Documented +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, + ElementType.LOCAL_VARIABLE}) +@Retention(RetentionPolicy.SOURCE) +public @interface Nullable { + +} diff -r a00fba8d5136 api.annotations.common/src/org/netbeans/api/annotations/common/SupressWarnings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api.annotations.common/src/org/netbeans/api/annotations/common/SupressWarnings.java Tue Jun 17 14:43:00 2008 +0200 @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.api.annotations.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Supress the warning reported by the code analyzing tool. + * + * @author Petr Hejl + */ +@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, + ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE}) +@Retention(RetentionPolicy.SOURCE) +public @interface SupressWarnings { + + /** + * The names of the warnings to supress. + */ + String[] value() default {}; + +} diff -r a00fba8d5136 apisupport.harness/release/build.xml --- a/apisupport.harness/release/build.xml Sat Jun 14 18:13:20 2008 +0200 +++ b/apisupport.harness/release/build.xml Tue Jun 17 14:43:00 2008 +0200 @@ -135,6 +135,7 @@ made subject to such option by the copyr + diff -r a00fba8d5136 apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java Sat Jun 14 18:13:20 2008 +0200 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java Tue Jun 17 14:43:00 2008 +0200 @@ -378,7 +378,13 @@ final class Evaluator implements Propert providers.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap("module.classpath", computeModuleClasspath(ml)))); // NOI18N Map buildDefaults = new HashMap(); buildDefaults.put("cp.extra", ""); // NOI18N - buildDefaults.put("cp", "${module.classpath}:${cp.extra}"); // NOI18N + ModuleEntry annotations = ml.getEntry("org.netbeans.api.annotations.common"); // NOI18N + if (annotations != null) { + providers.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap("annotations.common.cp", annotations.getJarLocation().getAbsolutePath()))); // NOI18N + buildDefaults.put("cp", "${module.classpath}:${annotations.common.cp}:${cp.extra}"); // NOI18N + } else { + buildDefaults.put("cp", "${module.classpath}:${cp.extra}"); // NOI18N + } buildDefaults.put("run.cp", computeRuntimeModuleClasspath(ml) + ":${cp.extra}:${build.classes.dir}"); // NOI18N baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()])); diff -r a00fba8d5136 nbbuild/cluster.properties --- a/nbbuild/cluster.properties Sat Jun 14 18:13:20 2008 +0200 +++ b/nbbuild/cluster.properties Tue Jun 17 14:43:01 2008 +0200 @@ -171,6 +171,7 @@ nb.cluster.platform.dir=platform8 nb.cluster.platform.dir=platform8 nb.cluster.platform.depends= nb.cluster.platform=\ + api.annotations.common,\ api.progress,\ api.visual,\ applemenu,\ diff -r a00fba8d5136 nbbuild/templates/common.xml --- a/nbbuild/templates/common.xml Sat Jun 14 18:13:20 2008 +0200 +++ b/nbbuild/templates/common.xml Tue Jun 17 14:43:01 2008 +0200 @@ -72,6 +72,7 @@ made subject to such option by the copyr + diff -r a00fba8d5136 nbbuild/templates/projectized.xml --- a/nbbuild/templates/projectized.xml Sat Jun 14 18:13:20 2008 +0200 +++ b/nbbuild/templates/projectized.xml Tue Jun 17 14:43:01 2008 +0200 @@ -144,7 +144,9 @@ If you are sure you want to build with J + + @@ -960,6 +962,7 @@ If you are sure you want to build with J + diff -r a00fba8d5136 openide.util/src/org/openide/util/Lookup.java --- a/openide.util/src/org/openide/util/Lookup.java Sat Jun 14 18:13:20 2008 +0200 +++ b/openide.util/src/org/openide/util/Lookup.java Tue Jun 17 14:43:01 2008 +0200 @@ -45,6 +45,8 @@ import java.util.Collections; import java.util.Collections; import java.util.Iterator; import java.util.Set; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; import org.openide.util.lookup.Lookups; import org.openide.util.lookup.ProxyLookup; @@ -98,6 +100,7 @@ public abstract class Lookup { * * @return the global lookup in the system */ + @NonNull public static synchronized Lookup getDefault() { if (defaultLookup != null) { return defaultLookup; @@ -185,7 +188,8 @@ public abstract class Lookup { * @return an object implementing the given class or null if no such * implementation is found */ - public abstract T lookup(Class clazz); + @CheckForNull + public abstract T lookup(@NonNull Class clazz); /** The general lookup method. Callers can get list of all instances and classes * that match the given template, request more info about @@ -198,7 +202,8 @@ public abstract class Lookup { * @param template a template describing the services to look for * @return an object containing the results */ - public abstract Result lookup(Template template); + @NonNull + public abstract Result lookup(@NonNull Template template); /** Look up the first item matching a given template. * Includes not only the instance but other associated information. @@ -207,7 +212,8 @@ public abstract class Lookup { * * @since 1.8 */ - public Item lookupItem(Template template) { + @CheckForNull + public Item lookupItem(@NonNull Template template) { Result res = lookup(template); Iterator> it = res.allItems().iterator(); return it.hasNext() ? it.next() : null; @@ -221,7 +227,8 @@ public abstract class Lookup { * @return a live object representing instances of that type * @since org.openide.util 6.10 */ - public Lookup.Result lookupResult(Class clazz) { + @NonNull + public Lookup.Result lookupResult(@NonNull Class clazz) { return lookup(new Lookup.Template(clazz)); } @@ -233,7 +240,8 @@ public abstract class Lookup { * @return all currently available instances of that type * @since org.openide.util 6.10 */ - public Collection lookupAll(Class clazz) { + @NonNull + public Collection lookupAll(@NonNull Class clazz) { return lookupResult(clazz).allInstances(); } @@ -283,7 +291,7 @@ public abstract class Lookup { /** Create a simple template matching by class. * @param type the class of service we are looking for (subclasses will match) */ - public Template(Class type) { + public Template(@CheckForNull Class type) { this(type, null, null); } @@ -292,7 +300,7 @@ public abstract class Lookup { * @param id the ID of the item/service we are looking for or null to leave unspecified * @param instance a specific known instance to look for or null to leave unspecified */ - public Template(Class type, String id, T instance) { + public Template(@CheckForNull Class type, @CheckForNull String id, @CheckForNull T instance) { this.type = extractType(type); this.id = id; this.instance = instance; @@ -308,6 +316,7 @@ public abstract class Lookup { * this will match any instance. * @return the class to search for */ + @NonNull public Class getType() { return type; } @@ -318,6 +327,7 @@ public abstract class Lookup { * * @since 1.8 */ + @CheckForNull public String getId() { return id; } @@ -330,6 +340,7 @@ public abstract class Lookup { * * @since 1.8 */ + @CheckForNull public T getInstance() { return instance; } @@ -337,6 +348,7 @@ public abstract class Lookup { /* Computes hashcode for this template. The hashcode is cached. * @return hashcode */ + @Override public int hashCode() { if (hashCode != 0) { return hashCode; @@ -352,7 +364,8 @@ public abstract class Lookup { * @param obj another template to check * @return true if so, false otherwise */ - public boolean equals(Object obj) { + @Override + public boolean equals(@CheckForNull Object obj) { if (!(obj instanceof Template)) { return false; } @@ -387,6 +400,7 @@ public abstract class Lookup { } /* for debugging */ + @NonNull public String toString() { return "Lookup.Template[type=" + type + ",id=" + id + ",instance=" + instance + "]"; // NOI18N } @@ -403,17 +417,18 @@ public abstract class Lookup { * * @param l the listener to add */ - public abstract void addLookupListener(LookupListener l); + public abstract void addLookupListener(@NonNull LookupListener l); /** Unregisters a listener previously added. * @param l the listener to remove */ - public abstract void removeLookupListener(LookupListener l); + public abstract void removeLookupListener(@NonNull LookupListener l); /** Get all instances in the result. The return value type * should be List instead of Collection, but it is too late to change it. * @return unmodifiable collection of all instances that will never change its content */ + @NonNull public abstract Collection allInstances(); /** Get all classes represented in the result. @@ -424,6 +439,7 @@ public abstract class Lookup { * * @since 1.8 */ + @NonNull public Set> allClasses() { return Collections.emptySet(); } @@ -436,6 +452,7 @@ public abstract class Lookup { * * @since 1.8 */ + @NonNull public Collection> allItems() { return Collections.emptyList(); } @@ -451,11 +468,13 @@ public abstract class Lookup { /** Get the instance itself. * @return the instance or null if the instance cannot be created */ + @CheckForNull public abstract T getInstance(); /** Get the implementing class of the instance. * @return the class of the item */ + @NonNull public abstract Class getType(); // XXX can it be null?? @@ -471,6 +490,7 @@ public abstract class Lookup { * * @return a string ID of the item */ + @NonNull public abstract String getId(); /** Get a human presentable name for the item. @@ -478,9 +498,11 @@ public abstract class Lookup { * lookup result in some part of a GUI. * @return the string suitable for presenting the object to a user */ + @NonNull public abstract String getDisplayName(); /* show ID for debugging */ + @NonNull public String toString() { return getId(); }