com.google.inject.spi.Message.getSources()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.google.inject.spi.Message.getSources()方法的一些代码示例,展示了Message.getSources()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getSources()方法的具体详情如下:
包路径:com.google.inject.spi.Message
类名称:Message
方法名:getSources

Message.getSources介绍

暂无

代码示例

代码示例来源:origin: com.google.inject/guice

  1. /** Prepends the list of sources to the given {@link Message} */
  2. static Message mergeSources(List<Object> sources, Message message) {
  3. List<Object> messageSources = message.getSources();
  4. // It is possible that the end of getSources() and the beginning of message.getSources() are
  5. // equivalent, in this case we should drop the repeated source when joining the lists. The
  6. // most likely scenario where this would happen is when a scoped binding throws an exception,
  7. // due to the fact that InternalFactoryToProviderAdapter applies the binding source when
  8. // merging errors.
  9. if (!sources.isEmpty()
  10. && !messageSources.isEmpty()
  11. && Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
  12. messageSources = messageSources.subList(1, messageSources.size());
  13. }
  14. return new Message(
  15. ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
  16. message.getMessage(),
  17. message.getCause());
  18. }

代码示例来源:origin: com.google.inject/guice

  1. fmt.format("%s) %s%n", thisIdx, errorMessage.getMessage());
  2. List<Object> dependencies = errorMessage.getSources();
  3. for (int i = dependencies.size() - 1; i >= 0; i--) {
  4. Object source = dependencies.get(i);

代码示例来源:origin: org.sonatype.sisu/sisu-guice

  1. /** Prepends the list of sources to the given {@link Message} */
  2. static Message mergeSources(List<Object> sources, Message message) {
  3. List<Object> messageSources = message.getSources();
  4. // It is possible that the end of getSources() and the beginning of message.getSources() are
  5. // equivalent, in this case we should drop the repeated source when joining the lists. The
  6. // most likely scenario where this would happen is when a scoped binding throws an exception,
  7. // due to the fact that InternalFactoryToProviderAdapter applies the binding source when
  8. // merging errors.
  9. if (!sources.isEmpty()
  10. && !messageSources.isEmpty()
  11. && Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
  12. messageSources = messageSources.subList(1, messageSources.size());
  13. }
  14. return new Message(
  15. ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
  16. message.getMessage(),
  17. message.getCause());
  18. }

代码示例来源:origin: com.jwebmp.inject/guice

  1. /** Prepends the list of sources to the given {@link Message} */
  2. static Message mergeSources(List<Object> sources, Message message) {
  3. List<Object> messageSources = message.getSources();
  4. // It is possible that the end of getSources() and the beginning of message.getSources() are
  5. // equivalent, in this case we should drop the repeated source when joining the lists. The
  6. // most likely scenario where this would happen is when a scoped binding throws an exception,
  7. // due to the fact that InternalFactoryToProviderAdapter applies the binding source when
  8. // merging errors.
  9. if (!sources.isEmpty()
  10. && !messageSources.isEmpty()
  11. && Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
  12. messageSources = messageSources.subList(1, messageSources.size());
  13. }
  14. return new Message(
  15. ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
  16. message.getMessage(),
  17. message.getCause());
  18. }

代码示例来源:origin: org.xbib/guice

  1. private Message merge(Message message) {
  2. List<Object> sources = Lists.newArrayList();
  3. sources.addAll(getSources());
  4. sources.addAll(message.getSources());
  5. return new Message(sources, message.getMessage(), message.getCause());
  6. }

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject

  1. /** Returns the formatted message for an exception with the specified messages. */
  2. public static String format(String heading, Collection<Message> errorMessages) {
  3. Formatter fmt = new Formatter().format(heading).format(":%n%n");
  4. int index = 1;
  5. boolean displayCauses = getOnlyCause(errorMessages) == null;
  6. for (Message errorMessage : errorMessages) {
  7. fmt.format("%s) %s%n", index++, errorMessage.getMessage());
  8. List<Object> dependencies = errorMessage.getSources();
  9. for (int i = dependencies.size() - 1; i >= 0; i--) {
  10. Object source = dependencies.get(i);
  11. formatSource(fmt, source);
  12. }
  13. Throwable cause = errorMessage.getCause();
  14. if (displayCauses && cause != null) {
  15. StringWriter writer = new StringWriter();
  16. cause.printStackTrace(new PrintWriter(writer));
  17. fmt.format("Caused by: %s", writer.getBuffer());
  18. }
  19. fmt.format("%n");
  20. }
  21. if (errorMessages.size() == 1) {
  22. fmt.format("1 error");
  23. } else {
  24. fmt.format("%s errors", errorMessages.size());
  25. }
  26. return fmt.toString();
  27. }

代码示例来源:origin: com.google/inject

  1. /** Returns the formatted message for an exception with the specified messages. */
  2. public static String format(String heading, Collection<Message> errorMessages) {
  3. Formatter fmt = new Formatter().format(heading).format(":%n%n");
  4. int index = 1;
  5. boolean displayCauses = getOnlyCause(errorMessages) == null;
  6. for (Message errorMessage : errorMessages) {
  7. fmt.format("%s) %s%n", index++, errorMessage.getMessage());
  8. List<Object> dependencies = errorMessage.getSources();
  9. for (int i = dependencies.size() - 1; i >= 0; i--) {
  10. Object source = dependencies.get(i);
  11. formatSource(fmt, source);
  12. }
  13. Throwable cause = errorMessage.getCause();
  14. if (displayCauses && cause != null) {
  15. StringWriter writer = new StringWriter();
  16. cause.printStackTrace(new PrintWriter(writer));
  17. fmt.format("Caused by: %s", writer.getBuffer());
  18. }
  19. fmt.format("%n");
  20. }
  21. if (errorMessages.size() == 1) {
  22. fmt.format("1 error");
  23. } else {
  24. fmt.format("%s errors", errorMessages.size());
  25. }
  26. return fmt.toString();
  27. }

代码示例来源:origin: Nextdoor/bender

  1. /** Returns the formatted message for an exception with the specified messages. */
  2. public static String format(String heading, Collection<Message> errorMessages) {
  3. Formatter fmt = new Formatter().format(heading).format(":%n%n");
  4. int index = 1;
  5. boolean displayCauses = getOnlyCause(errorMessages) == null;
  6. for (Message errorMessage : errorMessages) {
  7. fmt.format("%s) %s%n", index++, errorMessage.getMessage());
  8. List<Object> dependencies = errorMessage.getSources();
  9. for (int i = dependencies.size() - 1; i >= 0; i--) {
  10. Object source = dependencies.get(i);
  11. formatSource(fmt, source);
  12. }
  13. Throwable cause = errorMessage.getCause();
  14. if (displayCauses && cause != null) {
  15. StringWriter writer = new StringWriter();
  16. cause.printStackTrace(new PrintWriter(writer));
  17. fmt.format("Caused by: %s", writer.getBuffer());
  18. }
  19. fmt.format("%n");
  20. }
  21. if (errorMessages.size() == 1) {
  22. fmt.format("1 error");
  23. } else {
  24. fmt.format("%s errors", errorMessages.size());
  25. }
  26. return fmt.toString();
  27. }

代码示例来源:origin: org.xbib/guice

  1. /**
  2. * Returns the formatted message for an exception with the specified messages.
  3. */
  4. public static String format(String heading, Collection<Message> errorMessages) {
  5. Formatter fmt = new Formatter().format(heading).format(":%n%n");
  6. int index = 1;
  7. boolean displayCauses = getOnlyCause(errorMessages) == null;
  8. for (Message errorMessage : errorMessages) {
  9. fmt.format("%s) %s%n", index++, errorMessage.getMessage());
  10. List<Object> dependencies = errorMessage.getSources();
  11. for (int i = dependencies.size() - 1; i >= 0; i--) {
  12. Object source = dependencies.get(i);
  13. formatSource(fmt, source);
  14. }
  15. Throwable cause = errorMessage.getCause();
  16. if (displayCauses && cause != null) {
  17. StringWriter writer = new StringWriter();
  18. cause.printStackTrace(new PrintWriter(writer));
  19. fmt.format("Caused by: %s", writer.getBuffer());
  20. }
  21. fmt.format("%n");
  22. }
  23. if (errorMessages.size() == 1) {
  24. fmt.format("1 error");
  25. } else {
  26. fmt.format("%s errors", errorMessages.size());
  27. }
  28. return fmt.toString();
  29. }

代码示例来源:origin: org.sonatype.sisu/sisu-guice

  1. fmt.format("%s) %s%n", thisIdx, errorMessage.getMessage());
  2. List<Object> dependencies = errorMessage.getSources();
  3. for (int i = dependencies.size() - 1; i >= 0; i--) {
  4. Object source = dependencies.get(i);

代码示例来源:origin: com.jwebmp.inject/guice

  1. fmt.format("%s) %s%n", thisIdx, errorMessage.getMessage());
  2. List<Object> dependencies = errorMessage.getSources();
  3. for (int i = dependencies.size() - 1; i >= 0; i--) {
  4. Object source = dependencies.get(i);

代码示例来源:origin: Nextdoor/bender

  1. private Message merge(Message message) {
  2. List<Object> sources = Lists.newArrayList();
  3. sources.addAll(getSources());
  4. sources.addAll(message.getSources());
  5. return new Message(sources, message.getMessage(), message.getCause());
  6. }

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject

  1. private Message merge(Message message) {
  2. List<Object> sources = Lists.newArrayList();
  3. sources.addAll(getSources());
  4. sources.addAll(message.getSources());
  5. return new Message(sources, message.getMessage(), message.getCause());
  6. }

代码示例来源:origin: com.google/inject

  1. private Message merge(Message message) {
  2. List<Object> sources = Lists.newArrayList();
  3. sources.addAll(getSources());
  4. sources.addAll(message.getSources());
  5. return new Message(sources, message.getMessage(), message.getCause());
  6. }

代码示例来源:origin: org.guiceyfruit/guiceyfruit-core

  1. private Message merge(Message message) {
  2. List<Object> sources = Lists.newArrayList();
  3. sources.addAll(this.sources);
  4. sources.addAll(message.getSources());
  5. return new Message(stripDuplicates(sources), message.getMessage(), message.getCause());
  6. }

代码示例来源:origin: org.guiceyfruit/guiceyfruit-core

  1. fmt.format("%s) %s%n", index++, errorMessage.getMessage());
  2. List<Object> dependencies = errorMessage.getSources();
  3. for (int i = dependencies.size() - 1; i >= 0; i--) {
  4. Object source = dependencies.get(i);

相关文章