Package com.google.inject

Examples of com.google.inject.Inject.optional()


        if (javaxInject == null) {
          continue;
        }
        optional = false;
      } else {
        optional = guiceInject.optional();
      }

      if (optional) {
        errors.optionalConstructor(constructor);
      }
View Full Code Here


      {
        try
        {
          Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
          final IProxyTargetLocator locator = new GuiceProxyTargetLocator(field,
            bindingAnnotation, injectAnnotation != null ? injectAnnotation.optional() : false);

          if (wrapInProxies)
          {
            target = LazyInitProxyFactory.createProxy(field.getType(), locator);
          }
View Full Code Here

      javax.inject.Inject javaxInjectAnnotation = field.getAnnotation(javax.inject.Inject.class);
      if (!Modifier.isStatic(field.getModifiers()) && (injectAnnotation != null || javaxInjectAnnotation != null))
      {
        try
        {
          boolean optional = injectAnnotation != null && injectAnnotation.optional();
          Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
          final IProxyTargetLocator locator = new GuiceProxyTargetLocator(field, bindingAnnotation, optional);

          if (wrapInProxies)
          {
View Full Code Here

          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));

            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
View Full Code Here

            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here

      {
        try
        {
          Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
          final IProxyTargetLocator locator = new GuiceProxyTargetLocator(field,
            bindingAnnotation, injectAnnotation != null ? injectAnnotation.optional() : false);

          if (wrapInProxies)
          {
            target = LazyInitProxyFactory.createProxy(field.getType(), locator);
          }
View Full Code Here

  InjectionPoint(TypeLiteral<?> declaringType, Method method) {
    this.member = method;
    this.declaringType = declaringType;

    Inject inject = method.getAnnotation(Inject.class);
    this.optional = inject.optional();

    this.dependencies = forMember(method, declaringType, method.getParameterAnnotations());
  }

  InjectionPoint(TypeLiteral<?> declaringType, Constructor<?> constructor) {
View Full Code Here

  InjectionPoint(TypeLiteral<?> declaringType, Field field) {
    this.member = field;
    this.declaringType = declaringType;

    Inject inject = field.getAnnotation(Inject.class);
    this.optional = inject.optional();

    Annotation[] annotations = field.getAnnotations();

    Errors errors = new Errors(field);
    Key<?> key = null;
View Full Code Here

    Constructor<?> injectableConstructor = null;
    for (Constructor<?> constructor : rawType.getDeclaredConstructors()) {
      Inject inject = constructor.getAnnotation(Inject.class);
      if (inject != null) {
        if (inject.optional()) {
          errors.optionalConstructor(constructor);
        }

        if (injectableConstructor != null) {
          errors.tooManyConstructors(rawType);
View Full Code Here

      }

      try {
        injectionPoints.add(factory.create(typeLiteral, member, errors));
      } catch (ConfigurationException ignorable) {
        if (!inject.optional()) {
          errors.merge(ignorable.getErrorMessages());
        }
      }
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.