Search in sources :

Example 11 with CheckReturnValue

use of javax.annotation.CheckReturnValue in project JMRI by JMRI.

the class AbstractCatalogTree method getListenerRefs.

/* This allows a meaning full list of places where the bean is in use!*/
@CheckReturnValue
@Override
public synchronized ArrayList<String> getListenerRefs() {
    ArrayList<String> list = new ArrayList<>();
    Enumeration<PropertyChangeListener> en = listenerRefs.keys();
    while (en.hasMoreElements()) {
        PropertyChangeListener l = en.nextElement();
        list.add(listenerRefs.get(l));
    }
    return list;
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) CheckReturnValue(javax.annotation.CheckReturnValue)

Example 12 with CheckReturnValue

use of javax.annotation.CheckReturnValue in project JMRI by JMRI.

the class AbstractCatalogTree method getPropertyChangeListenersByReference.

@CheckReturnValue
@Override
public synchronized PropertyChangeListener[] getPropertyChangeListenersByReference(String name) {
    ArrayList<PropertyChangeListener> list = new ArrayList<>();
    Enumeration<PropertyChangeListener> en = register.keys();
    while (en.hasMoreElements()) {
        PropertyChangeListener l = en.nextElement();
        if (register.get(l).equals(name)) {
            list.add(l);
        }
    }
    return list.toArray(new PropertyChangeListener[list.size()]);
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) CheckReturnValue(javax.annotation.CheckReturnValue)

Example 13 with CheckReturnValue

use of javax.annotation.CheckReturnValue in project core-java by SpineEventEngine.

the class HandlerMethod method getHandledMessageClasses.

/**
     * Returns types of messages handled by the passed class.
     *
     * @return immutable set of message classes or an empty set
     */
@CheckReturnValue
static ImmutableSet<Class<? extends Message>> getHandledMessageClasses(Class<?> cls, Predicate<Method> predicate) {
    final ImmutableSet.Builder<Class<? extends Message>> builder = ImmutableSet.builder();
    for (Method method : cls.getDeclaredMethods()) {
        final boolean methodMatches = predicate.apply(method);
        if (methodMatches) {
            final Class<? extends Message> firstParamType = getFirstParamType(method);
            builder.add(firstParamType);
        }
    }
    return builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Message(com.google.protobuf.Message) Method(java.lang.reflect.Method) CheckReturnValue(javax.annotation.CheckReturnValue)

Aggregations

CheckReturnValue (javax.annotation.CheckReturnValue)13 VisibleForTesting (com.google.common.annotations.VisibleForTesting)4 ArrayList (java.util.ArrayList)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 Predicate (com.google.common.base.Predicate)1 Supplier (com.google.common.base.Supplier)1 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1 BugCheckerInfo (com.google.errorprone.BugCheckerInfo)1 BugPattern (com.google.errorprone.BugPattern)1 SeverityLevel (com.google.errorprone.BugPattern.SeverityLevel)1 ErrorProneOptions (com.google.errorprone.ErrorProneOptions)1 Severity (com.google.errorprone.ErrorProneOptions.Severity)1 InvalidCommandLineOptionException (com.google.errorprone.InvalidCommandLineOptionException)1 CompatibleWith (com.google.errorprone.annotations.CompatibleWith)1 BugChecker (com.google.errorprone.bugpatterns.BugChecker)1 Any (com.google.protobuf.Any)1