Package com.google.inject.spi

Examples of com.google.inject.spi.Message


  static void checkConfiguration(boolean condition, String format, Object... args) {
    if (condition) {
      return;
    }

    throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
  }
View Full Code Here


    T oldValue = getOnlyElement(filter(existingBindings.keySet(), equalTo(newValue)));
    String oldString = oldValue.toString();
    String newString = newValue.toString();
    if (Objects.equal(oldString, newString)) {
      // When the value strings match, just show the source of the bindings
      return new ConfigurationException(ImmutableSet.of(new Message(Errors.format(
          "Set injection failed due to duplicated element \"%s\""
              + "\n    Bound at %s\n    Bound at %s",
          newValue,
          duplicateBinding.getSource(),
          binding.getSource()))));
    } else {
      // When the value strings don't match, include them both as they may be useful for debugging
      return new ConfigurationException(ImmutableSet.of(new Message(Errors.format(
          "Set injection failed due to multiple elements comparing equal:"
              + "\n    \"%s\"\n        bound at %s"
              + "\n    \"%s\"\n        bound at %s",
          oldValue,
          duplicateBinding.getSource(),
View Full Code Here

      return reference;
    }

    NullPointerException npe = new NullPointerException(name);
    throw new ConfigurationException(ImmutableSet.of(
        new Message(npe.toString(), npe)));
  }
View Full Code Here

          "at " + MissingParameter.class.getName() + ".<init>(BinderTest.java:");
    }
  }

  public void testUserReportedError() {
    final Message message = new Message(getClass(), "Whoops!");
    try {
      Guice.createInjector(new AbstractModule() {
        @Override
        protected void configure() {
          addError(message);
View Full Code Here

  public void testUserReportedErrorsAreAlsoLogged() {
    try {
      Guice.createInjector(new AbstractModule() {
        @Override
        protected void configure() {
          addError(new Message("Whoops!", new IllegalArgumentException()));
        }
      });
      fail();
    } catch (CreationException expected) {
    }
View Full Code Here

    Preconditions.checkNotNull(binder);
    String source = String.format(
        "%s field %s",
        field.getDeclaringClass().getName(),
        field.getName());
    throw new BoundFieldException(new Message(source, String.format(format, args)));
  }
View Full Code Here

    // that is not bound?
    return null;
  }

  protected Void visitOther(Element element) {
    visit(new Message(element.getSource(), "Ignoring unsupported Module element: " + element));
    return null;
  }
View Full Code Here

    if (BindConstantBinding.isConstantKey(targetKey)) {
      Context context = Context.forElement(instanceBinding);
      bindingsCollection.addBinding(targetKey,
          bindingFactory.getBindConstantBinding(targetKey, instance, context));
    } else {
      messages.add(new Message(instanceBinding.getSource(),
          PrettyPrinter.format("Instance binding not supported; key=%s, inst=%s",
              targetKey, instance)));
    }

    return null;
View Full Code Here

    bindingsCollection.addDependency(new Dependency(Dependency.GINJECTOR, targetKey,
        Context.forElement(sourceElement).toString()));
  }

  protected Void visitOther(com.google.inject.Binding<? extends T> binding) {
    messages.add(new Message(binding.getSource(), PrettyPrinter.format(
        "Unsupported binding provided for key: %s: %s", targetKey, binding)));
    return null;
  }
View Full Code Here

  }

  // TODO(schmitt): We don't support this right now in any case, but it's
  // strange to be using the Guice Scope instead of javax.inject.Scope
  public Void visitScope(Scope scope) {
    messages.add(new Message(PrettyPrinter.format("Explicit scope unsupported: key=%s scope=%s",
        targetKey, scope)));
    return null;
  }
View Full Code Here

TOP

Related Classes of com.google.inject.spi.Message

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.