Get reference to an instance of the specified watcher type.

@param <T> watcher type
@param watcherType watcher type
@return optional watcher instance
495799
public static <T extends JUnitWatcher> Optional<T> getAttachedWatcher(Class<T> watcherType) {
        Optional<T> watcher = CreateTest.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        watcher = Run.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        watcher = RunAnnouncer.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        return RunReflectiveCall.getAttachedWatcher(watcherType);
    }
553591
void registerQueryWatcher(@NotNull ApolloQueryWatcher queryWatcher) {
    checkNotNull(queryWatcher, "queryWatcher == null");
    OperationName operationName = queryWatcher.operation().name();
    registerCall(activeQueryWatchers, operationName, queryWatcher);
  }
1154818
public static <T> TypeReference<T> get(Class<T> type) {
		return new SimpleTypeReference<T>(type);
	}
1325102
@SuppressWarnings("unchecked")
  @NonNull
  public final GenericType<? super T> getSupertype(@NonNull Class<? super T> superclass) {
    return new GenericType(token.getSupertype(superclass));
  }
1105410
def _pfp__watch(self, watcher):
        
        if self._pfp__parent is not None and isinstance(self._pfp__parent, Union):
            self._pfp__parent._pfp__watch(watcher)
        else:
            self._pfp__watchers.append(watcher)
927049
public static <T> TypeChecker<Collection<? extends T>> tCollection(TypeChecker<? extends T> elementChecker) {
        return new CollectionTypeChecker<>(Collection.class, elementChecker);
    }
1308312
public static <T extends MalisisGui> T current(Class<T> type)
	{
		GuiScreen gui = Minecraft.getMinecraft().currentScreen;
		if (gui == null || !(gui instanceof MalisisGui))
			return null;
		try
		{
			return type.cast(gui);
		}
		catch (ClassCastException e)
		{
			return null;
		}
	}
635755
private void processWatcher(MethodSpec.Builder createdMethodBuilder, ExecutableElement method) {
    Watch watch = method.getAnnotation(Watch.class);

    String exposedMethodName = exposeExistingJavaMethodToJs(method);
    String watcherTriggerMethodName = addNewMethodToProto();

    MethodSpec.Builder watcherMethodBuilder = MethodSpec
        .methodBuilder(watcherTriggerMethodName)
        .addModifiers(Modifier.PUBLIC)
        .addAnnotation(JsMethod.class)
        .returns(Object.class);

    String[] valueSplit = watch.value().split("\\.");

    String currentExpression = "";
    for (int i = 0; i < valueSplit.length - 1; i++) {
      currentExpression += valueSplit[i];
      watcherMethodBuilder.addStatement("if ($L == null) return null", currentExpression);
      currentExpression += ".";
    }

    watcherMethodBuilder.addStatement("return $L", watch.value());

    componentExposedTypeBuilder.addMethod(watcherMethodBuilder.build());

    createdMethodBuilder
        .addStatement("vue().$L(p.$L, p.$L, $T.of($L, $L))", "$watch",
            watcherTriggerMethodName, exposedMethodName, WatchOptions.class, watch.isDeep(),
            watch.isImmediate());
  }
1003139
@Deprecated
    public void weakAddWatcher(Listener watcher) {
        if (watcher == null) {
            throw new IllegalArgumentException("Null watcher added");
        }

        synchronized (mutex) {
            if (watcherExecutor.isShutdown()) {
                throw new IllegalStateException("Adding watcher on closed FileWatcher");
            }
            watchers.add(new WeakReference<>(watcher)::get);
        }
    }
496584
protected final ContentViewer newInstance(String type,
                                              InputStream data,
                                              boolean viewOnly)
            throws IOException {
        ContentViewer instance = null;
        try {
            instance = this.getClass().newInstance();
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
        instance.init(type, data, viewOnly);
        return instance;
    }
617139
public static void visit(Object instance, TypeToken<?> inspectType, Visitor firstVisitor, Visitor... moreVisitors) {

    try {
      List<Visitor> visitors = ImmutableList.<Visitor>builder().add(firstVisitor).add(moreVisitors).build();

      for (TypeToken<?> type : inspectType.getTypes().classes()) {
        if (Object.class.equals(type.getRawType())) {
          break;
        }

        for (Field field : type.getRawType().getDeclaredFields()) {
          if (!field.isAccessible()) {
            field.setAccessible(true);
          }
          for (Visitor visitor : visitors) {
            visitor.visit(instance, inspectType, type, field);
          }
        }

        for (Method method : type.getRawType().getDeclaredMethods()) {
          if (!method.isAccessible()) {
            method.setAccessible(true);
          }
          for (Visitor visitor : visitors) {
            visitor.visit(instance, inspectType, type, method);
          }
        }
      }
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
843831
public int addWatcher(TextWatcher watcher){
        int id = mWatchers.size();
        addWatcher(id, watcher);
        return id;
    }
734527
protected Method getSetter(Class type, String name)
    {
        return introspector(type).getSetter( toJavaIdentifierForm(name));
    }
451053
@Override
    public <T> T asFacet(Class<T> facetType)
    {
        if (facetType == SpanProvider.class)
        {
            return facetType.cast(new SpanProviderFacet());
        }

        if (facetType == SeekableReader.class && _scanner.isBufferedInput())
        {
            return facetType.cast(new SeekableReaderFacet());
        }

        return super.asFacet(facetType);
    }
779950
@SuppressWarnings("unchecked")
    public ArrayList<Notification> getByType(Class<?> type) {
        List<?> byType = this.getByType();
        if (type.isAssignableFrom(InteractionNotification.class))
            return (ArrayList<Notification>) byType.get(0);
        if (type.isAssignableFrom(ValueNotification.class))
            return (ArrayList<Notification>) byType.get(1);
        return null;
    }
1219932
@Nullable
  private WatchKey check(@Nullable WatchKey key) {
    if (key == poison) {
      // ensure other blocking threads get the poison
      queue.offer(poison);
      throw new ClosedWatchServiceException();
    }
    return key;
  }
132539
@Override
    public <T extends Principal> Set<T> getPrincipalsByType(Class<T> type) {
        //Get the caller principal from the caller subject
        Subject callerSubject = getCallerSubject();

        if (callerSubject != null) {
            //Get the prinicipals by type
            Set<T> principals = callerSubject.getPrincipals(type);
            return principals;
        }

        return null;

    }