Java Collections.singletonList Examples

Java Collections.singletonList - 30 examples found. These are the top rated real world Java examples of java.util.Collections.singletonList extracted from open source projects. You can rate examples to help us improve the quality of examples.
  @Override
  public void drawScreen(int x, int y, float f) {
    super.drawScreen(x, y, f);

    String text1 =
        this.machine.storage.getEnergyStored()
            + "/"
            + this.machine.storage.getMaxEnergyStored()
            + " RF";
    if (x >= guiLeft + 16 && y >= guiTop + 5 && x <= guiLeft + 23 && y <= guiTop + 89) {
      this.func_146283_a(Collections.singletonList(text1), x, y);
    }
    String text3 =
        this.machine.tank.getFluidAmount()
            + "/"
            + this.machine.tank.getCapacity()
            + " mB "
            + FluidRegistry.WATER.getLocalizedName(this.machine.tank.getFluid());
    if (x >= guiLeft + 27 && y >= guiTop + 5 && x <= guiLeft + 33 && y <= guiTop + 70) {
      this.func_146283_a(Collections.singletonList(text3), x, y);
    }

    String text2 =
        this.machine.coffeeCacheAmount
            + "/"
            + this.machine.coffeeCacheMaxAmount
            + " "
            + StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.coffee");
    if (x >= guiLeft + 40 && y >= guiTop + 25 && x <= guiLeft + 49 && y <= guiTop + 56) {
      this.func_146283_a(Collections.singletonList(text2), x, y);
    }
  }
  @SuppressWarnings("unchecked")
  @Before
  public void setUp() throws Exception {
    messageConverter = createMock(HttpMessageConverter.class);
    expect(messageConverter.getSupportedMediaTypes())
        .andReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
    replay(messageConverter);

    processor =
        new RequestResponseBodyMethodProcessor(
            Collections.<HttpMessageConverter<?>>singletonList(messageConverter));
    reset(messageConverter);

    Method handle = getClass().getMethod("handle1", String.class, Integer.TYPE);
    paramRequestBodyString = new MethodParameter(handle, 0);
    paramInt = new MethodParameter(handle, 1);
    returnTypeString = new MethodParameter(handle, -1);
    returnTypeInt = new MethodParameter(getClass().getMethod("handle2"), -1);
    returnTypeStringProduces = new MethodParameter(getClass().getMethod("handle3"), -1);
    paramValidBean = new MethodParameter(getClass().getMethod("handle4", SimpleBean.class), 0);

    mavContainer = new ModelAndViewContainer();

    servletRequest = new MockHttpServletRequest();
    servletResponse = new MockHttpServletResponse();
    webRequest = new ServletWebRequest(servletRequest, servletResponse);
  }
  /** Test for creating zobjects with relationships */
  @Test
  @SuppressWarnings("serial")
  public void createAndDeleteRelated() throws Exception {
    SaveResult saveResult =
        module.create(ZObjectType.Account, Collections.singletonList(testAccount())).get(0);
    assertTrue(saveResult.isSuccess());

    final String accountId = saveResult.getId();
    try {
      SaveResult result =
          module
              .create(
                  ZObjectType.Contact,
                  Collections.<Map<String, Object>>singletonList(
                      new HashMap<String, Object>() {
                        {
                          put("Country", "US");
                          put("FirstName", "John");
                          put("LastName", "Doe");
                          put("AccountId", accountId);
                        }
                      }))
              .get(0);
      assertTrue(result.isSuccess());

      DeleteResult deleteResult =
          module.delete(ZObjectType.Contact, Arrays.asList(result.getId())).get(0);
      assertTrue(deleteResult.isSuccess());
    } finally {
      module.delete(ZObjectType.Account, Arrays.asList(accountId)).get(0);
    }
  }
  public void testConfigureRequestGoals() throws Exception {
    Properties props = new Properties();
    InvokerProperties facade = new InvokerProperties(props);

    InvocationRequest request = new DefaultInvocationRequest();

    request.setGoals(Collections.singletonList("test"));
    facade.configureInvocation(request, 0);
    assertEquals(Collections.singletonList("test"), request.getGoals());

    props.setProperty("invoker.goals", "verify");
    facade.configureInvocation(request, 0);
    assertEquals(Collections.singletonList("verify"), request.getGoals());

    props.setProperty("invoker.goals", "   ");
    facade.configureInvocation(request, 0);
    assertEquals(Arrays.asList(new String[0]), request.getGoals());

    props.setProperty("invoker.goals", "  clean , test   verify  ");
    facade.configureInvocation(request, 0);
    assertEquals(Arrays.asList(new String[] {"clean", "test", "verify"}), request.getGoals());

    props.setProperty("invoker.goals", "");
    facade.configureInvocation(request, 0);
    assertEquals(Arrays.asList(new String[0]), request.getGoals());
  }
  private static List<XmlElementDescriptor> computeRequiredSubTags(XmlElementsGroup group) {

    if (group.getMinOccurs() < 1) return Collections.emptyList();
    switch (group.getGroupType()) {
      case LEAF:
        XmlElementDescriptor descriptor = group.getLeafDescriptor();
        return descriptor == null
            ? Collections.<XmlElementDescriptor>emptyList()
            : Collections.singletonList(descriptor);
      case CHOICE:
        LinkedHashSet<XmlElementDescriptor> set = null;
        for (XmlElementsGroup subGroup : group.getSubGroups()) {
          List<XmlElementDescriptor> descriptors = computeRequiredSubTags(subGroup);
          if (set == null) {
            set = new LinkedHashSet<XmlElementDescriptor>(descriptors);
          } else {
            set.retainAll(descriptors);
          }
        }
        if (set == null || set.isEmpty()) {
          return Collections.singletonList(null); // placeholder for smart completion
        }
        return new ArrayList<XmlElementDescriptor>(set);

      default:
        ArrayList<XmlElementDescriptor> list = new ArrayList<XmlElementDescriptor>();
        for (XmlElementsGroup subGroup : group.getSubGroups()) {
          list.addAll(computeRequiredSubTags(subGroup));
        }
        return list;
    }
  }
 protected OutboundEndpoint createTestOutboundEndpoint(
     String uri,
     Filter filter,
     SecurityFilter securityFilter,
     Transformer transformer,
     Transformer responseTransformer,
     MessageExchangePattern exchangePattern,
     TransactionConfig txConfig)
     throws EndpointException, InitialisationException {
   EndpointURIEndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder(uri, muleContext);
   if (filter != null) {
     endpointBuilder.addMessageProcessor(new MessageFilter(filter));
   }
   if (securityFilter != null) {
     endpointBuilder.addMessageProcessor(new SecurityFilterMessageProcessor(securityFilter));
   }
   if (transformer != null) {
     endpointBuilder.setMessageProcessors(
         Collections.<MessageProcessor>singletonList(transformer));
   }
   if (responseTransformer != null) {
     endpointBuilder.setResponseMessageProcessors(
         Collections.<MessageProcessor>singletonList(responseTransformer));
   }
   endpointBuilder.setExchangePattern(exchangePattern);
   endpointBuilder.setTransactionConfig(txConfig);
   customizeEndpointBuilder(endpointBuilder);
   return endpointBuilder.buildOutboundEndpoint();
 }