Code example for TypeToken

Methods: getType

0
    super(new InjectorRegistryBacking(injector));
    this.injector = injector;
  } 
 
  public <T> Optional<T> maybeGet(TypeToken<T> type) {
    @SuppressWarnings("unchecked") TypeLiteral<T> typeLiteral = (TypeLiteral<T>) TypeLiteral.get(type.getType());
    try { 
      return Optional.of(injector.getInstance(Key.get(typeLiteral)));
    } catch (ConfigurationException e) { 
      return Optional.empty();
    } 
  } 
 
}