Package com.google.inject

Examples of com.google.inject.TypeLiteral$SimpleTypeLiteral


                        clazz, annotation);
                }
            }
            else if ( foundBindingClass instanceof Type )
            {
                TypeLiteral typeLiteral = TypeLiteral.get((Type)foundBindingClass);
                if ( annotation.multiple() )
                {
                    Multibinder<?> multibinder = Multibinder.newSetBinder(binder(), typeLiteral);
                    //noinspection unchecked
                    applyScope(
View Full Code Here


            checkState( !isTypeConflicts, "   Found multiple annotation @%s for type: %s; binding skipped!.",
                        Mock.class.getSimpleName(), type );
            for ( final Field field : fields )
            {
                final TypeLiteral literal = TypeLiteral.get( type );
                final Mock annoBy = field.getAnnotation( Mock.class );
                final Object mock = this.mockedFields.get( field );
                if ( annoBy.annotatedWith() != Mock.NoAnnotation.class )
                {
                    bind( literal ).annotatedWith( annoBy.annotatedWith() ).toInstance( mock );
View Full Code Here

            // for any types that don't have duplicates, bind instances.
            for (Type type : fieldsByType.keySet()) {
                Collection<Field> fields = fieldsByType.get(type);
                if (fields.size() == 1) {
                    Field field = Iterables.getOnlyElement(fields);
                    TypeLiteral literal = TypeLiteral.get(type);
                    bind(literal).toInstance(this.fields.get(field));
                }
            }
        }
View Full Code Here

      // for any types that don't have duplicates, bind instances.
      for ( Type type : fieldsByType.keySet() ) {
        Collection<Field> fields = fieldsByType.get(type);
        if ( fields.size() == 1 ) {
          Field field = Iterables.getOnlyElement(fields);
          TypeLiteral literal = TypeLiteral.get(type);
          bind(literal).toInstance(this.fields.get(field));
        }
      }
    }
View Full Code Here

    // Public methods
    // ----------------------------------------------------------------------

    public Iterable<BeanEntry> locate( final Key key )
    {
        final TypeLiteral type = key.getTypeLiteral();
        RankedBindings bindings = fetchBindings( type, null );
        if ( null == bindings )
        {
            synchronized ( cachedBindings ) // perform new lookup
            {
View Full Code Here

      throw new ConfigurationException(((Errors)localObject).getMessages());
    }
    if (paramTypeLiteral.getRawType() == Provider.class)
    {
      localObject = (ParameterizedType)localType;
      TypeLiteral localTypeLiteral = TypeLiteral.get(Types.providerOf(localObject.getActualTypeArguments()[0]));
      return localTypeLiteral;
    }
    Object localObject = (TypeLiteral)PRIMITIVE_TO_WRAPPER.get(paramTypeLiteral);
    return localObject != null ? localObject : paramTypeLiteral;
  }
View Full Code Here

    BindingImpl localBindingImpl = this.state.getExplicitBinding(localKey);
    if ((localBindingImpl == null) || (!localBindingImpl.isConstant()))
      return null;
    String str = (String)localBindingImpl.getProvider().get();
    Object localObject1 = localBindingImpl.getSource();
    TypeLiteral localTypeLiteral = paramKey.getTypeLiteral();
    TypeConverterBinding localTypeConverterBinding = this.state.getConverter(str, localTypeLiteral, paramErrors, localObject1);
    if (localTypeConverterBinding == null)
      return null;
    try
    {
      Object localObject2 = localTypeConverterBinding.getTypeConverter().convert(str, localTypeLiteral);
      if (localObject2 == null)
        throw paramErrors.converterReturnedNull(str, localObject1, localTypeLiteral, localTypeConverterBinding).toException();
      if (!localTypeLiteral.getRawType().isInstance(localObject2))
        throw paramErrors.conversionTypeError(str, localObject1, localTypeLiteral, localTypeConverterBinding, localObject2).toException();
      return new ConvertedConstantBindingImpl(this, paramKey, localObject2, localBindingImpl, localTypeConverterBinding);
    }
    catch (ErrorsException localErrorsException)
    {
View Full Code Here

    }

    public void validate(Errors paramErrors)
      throws ErrorsException
    {
      TypeLiteral localTypeLiteral = TypeLiteral.get(this.instance.getClass());
      this.membersInjector = this.injector.membersInjectorStore.get(localTypeLiteral, paramErrors.withSource(this.source));
    }
View Full Code Here

    BindingImpl localBindingImpl = this.state.getExplicitBinding(localKey);
    if ((localBindingImpl == null) || (!localBindingImpl.isConstant()))
      return null;
    String str = (String)localBindingImpl.getProvider().get();
    Object localObject1 = localBindingImpl.getSource();
    TypeLiteral localTypeLiteral = paramKey.getTypeLiteral();
    TypeConverterBinding localTypeConverterBinding = this.state.getConverter(str, localTypeLiteral, paramErrors, localObject1);
    if (localTypeConverterBinding == null)
      return null;
    try
    {
      Object localObject2 = localTypeConverterBinding.getTypeConverter().convert(str, localTypeLiteral);
      if (localObject2 == null)
        throw paramErrors.converterReturnedNull(str, localObject1, localTypeLiteral, localTypeConverterBinding).toException();
      if (!localTypeLiteral.getRawType().isInstance(localObject2))
        throw paramErrors.conversionTypeError(str, localObject1, localTypeLiteral, localTypeConverterBinding, localObject2).toException();
      return new ConvertedConstantBindingImpl(this, paramKey, localObject2, localBindingImpl, localTypeConverterBinding);
    }
    catch (ErrorsException localErrorsException)
    {
View Full Code Here

      throw new ConfigurationException(((Errors)localObject).getMessages());
    }
    if (paramTypeLiteral.getRawType() == Provider.class)
    {
      localObject = (ParameterizedType)localType;
      TypeLiteral localTypeLiteral = TypeLiteral.get(Types.providerOf(localObject.getActualTypeArguments()[0]));
      return localTypeLiteral;
    }
    Object localObject = (TypeLiteral)PRIMITIVE_TO_WRAPPER.get(paramTypeLiteral);
    return localObject != null ? localObject : paramTypeLiteral;
  }
View Full Code Here

TOP

Related Classes of com.google.inject.TypeLiteral$SimpleTypeLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.