Get reference to an instance of the specified listener type.

@param <T> listener type
@param listenerType listener type
@return optional listener instance
485412
public static <T extends RunListener> Optional<T> getAttachedListener(Class<T> listenerType) {
        return Run.getAttachedListener(listenerType);
    }
446644
private ArrayList getListener()
    {
        if (_listeners != null)
            return _listeners;
        synchronized (this) {
            if (_listeners != null)
                return _listeners;
            _listeners = new ArrayList();
        }
        return _listeners;
    }
1284434
private static void parseListeners(final ListenerType listenerType, final WebApp webApp) {
		addWebListener(webApp, listenerType.getListenerClass().getValue());
	}
509272
public void addListener(InstallEventListener listener, String notificationType) {
        if (listener == null || notificationType == null)
            return;
        if (notificationType.isEmpty())
            return;
        if (listenersMap == null) {
            listenersMap = new HashMap<String, Collection<InstallEventListener>>();
        }
        Collection<InstallEventListener> listeners = listenersMap.get(notificationType);
        if (listeners == null) {
            listeners = new ArrayList<InstallEventListener>(1);
            listenersMap.put(notificationType, listeners);
        }
        listeners.add(listener);
    }
485756
@SuppressWarnings("unchecked")
    public <T> TypeHandler<T> getInstance(Class<?> javaTypeClass, Class<?> typeHandlerClass) {
        if (javaTypeClass != null) {
          try {
            Constructor<?> c = typeHandlerClass.getConstructor(Class.class);
            return (TypeHandler<T>) c.newInstance(javaTypeClass);
          } catch (NoSuchMethodException ignored) {
            // ignored
          } catch (Exception e) {
            throw new TypeException("Failed invoking constructor for handler " + typeHandlerClass, e);
          }
        }
        try {
          Constructor<?> c = typeHandlerClass.getConstructor();
          return (TypeHandler<T>) c.newInstance();
        } catch (Exception e) {
          throw new TypeException("Unable to find a usable constructor for " + typeHandlerClass, e);
        }
      }
872346
public synchronized <T extends EventListener> void remove(Class<T> type, T listener) {
		assert listener != null;
		// Is l on the list?
		int index = -1;
		for (int i = this.listeners.length - 2; i >= 0; i -= 2) {
			if ((this.listeners[i] == type) && (this.listeners[i + 1].equals(listener))) {
				index = i;
				break;
			}
		}

		// If so,  remove it
		if (index != -1) {
			final Object[] tmp = new Object[this.listeners.length - 2];
			// Copy the list up to index
			System.arraycopy(this.listeners, 0, tmp, 0, index);
			// Copy from two past the index, up to
			// the end of tmp (which is two elements
			// shorter than the old list)
			if (index < tmp.length) {
				System.arraycopy(this.listeners, index + 2, tmp, index,
						tmp.length - index);
			}
			// set the listener array to the new array or null
			this.listeners = (tmp.length == 0) ? NULL : tmp;
		}
	}
1188667
protected Future<T> addToListeners(
    final GenericCompletionListener<? extends Future<T>> listener) {
    if (listener == null) {
      throw new IllegalArgumentException("The listener can't be null.");
    }

    synchronized(this) {
      listeners.add(listener);
    }

    if(isDone()) {
      notifyListeners();
    }

    return this;
  }
1219680
public java.util.List<Listener> getListeners() {
        if (listeners == null) {
            listeners = new com.amazonaws.internal.SdkInternalList<Listener>();
        }
        return listeners;
    }
895750
@Override
   @SuppressWarnings("unchecked")
   public <E, T extends Resource<E>> T getChildOfType(final Class<T> type, final String name) throws ResourceException
   {
      T result;
      Resource<?> child = getChild(name);
      if (type.isAssignableFrom(child.getClass()))
      {
         result = (T) child;
      }
      else if (child.exists())
      {
         throw new ResourceException("Requested resource [" + name + "] was not of type [" + type.getName()
                  + "], but was instead [" + child.getClass().getName() + "]");
      }
      else
      {
         E underlyingResource = (E) child.getUnderlyingResourceObject();
         result = getResourceFactory().create(type, underlyingResource);
      }
      return result;
   }
736833
public static InternalListenerMetadata introspect(Class<?> listenerClass) {
    InternalListenerMetadata cachedMetadata = cache.get(listenerClass);
    if (cachedMetadata != null) {
      return cachedMetadata;
    }
    synchronized (listenerClass) {
      cachedMetadata = cache.get(listenerClass);
      if (cachedMetadata != null) {
        return cachedMetadata;
      }
      InternalListenerIntrospector introspector = new InternalListenerIntrospector(listenerClass);
      introspector.introspect();
      cache.put(listenerClass, introspector.metadata);
      return introspector.metadata;
    }
  }
494873
@SafeVarargs
    public static <T extends ParseTreeListener> T create(Class<T> type, T... delegates) {
        ImmutableList<T> listeners = ImmutableList.copyOf(delegates);
        return Reflection.newProxy(type, new AbstractInvocationHandler() {

            @Override
            @ParametersAreNonnullByDefault
            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
                for (T listener : listeners) {
                    method.invoke(listener, args);
                }
                return null;
            }

            @Override
            public String toString() {
                return MoreObjects.toStringHelper("CompositeParseTreeListener")
                        .add("listeners", listeners)
                        .toString();
            }
        });

    }
259275
public Optional<MapperInstance> getKeySerializer( JType type ) {
        return Optional.fromNullable( keySerializers.get( type.getQualifiedSourceName() ) );
    }
933402
def add_listener(self, listener_type, callback):
        
        self.listener_type= listener_type
        if listener_type == 'objectHovered':
            self.listener_callback_source_hover= callback
        elif listener_type == 'objectClicked':
            self.listener_callback_source_click= callback
        elif listener_type == 'click':
            self.listener_callback_click= callback
        elif listener_type == 'select':
            self.listener_callback_select= callback

        self.listener_flag= not self.listener_flag
530905
public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
		return getAnnotatedElement().getAnnotation(annotationType);
	}
1356346
public Optional<MapperInstance> getDeserializer( JType type ) {
        return Optional.fromNullable( deserializers.get( type.getQualifiedSourceName() ) );
    }
315304
public function getListenerPriority($eventType, $listener)
    {
        if (isset($this->listeners[$eventType])) {
            foreach ($this->listeners[$eventType] as $priority => $listeners) {
                if (false !== ($key = array_search($listener, $listeners, true))) {
                    return $priority;
                }
            }
        }

        return null;
    }
1000533
protected static void requestNotificationOnChange(JvmType type, Runnable listener) {
		Resource resource = type.eResource();
		if (resource instanceof TypeResource) {
			IMirror mirror = ((TypeResource) resource).getMirror();
			if (mirror instanceof IMirrorExtension) {
				if (((IMirrorExtension) mirror).isSealed())
					return;
			}
		}
		Notifier notifier = type;
		if (resource != null) {
			if (resource.getResourceSet() != null)
				notifier = resource.getResourceSet();
			else
				notifier = resource;
		}
		JvmTypeChangeDispatcher dispatcher = JvmTypeChangeDispatcher.findResourceChangeDispatcher(notifier);
		dispatcher.requestNotificationOnChange(type, listener);
	}