Java Arrays.asList Examples

Java Arrays.asList - 30 examples found. These are the top rated real world Java examples of java.util.Arrays.asList extracted from open source projects. You can rate examples to help us improve the quality of examples.
  @SuppressWarnings("unchecked")
  protected void handleMouseDown(ListViewEvent<M> e) {
    if (locked) return;
    M sel = listStore.getAt(e.getIndex());

    if (isSelected(sel) && !e.isControlKey()) {
      return;
    }

    if (selectionMode == SelectionMode.SINGLE) {
      if (isSelected(sel) && e.isControlKey()) {
        deselect(sel);
      } else if (!isSelected(sel)) {
        select(sel, false);
      }
    } else {
      if (e.isShiftKey() && lastSelected != null) {
        int last = listStore.indexOf(lastSelected);
        int index = e.getIndex();
        int a = (last > index) ? index : last;
        int b = (last < index) ? index : last;
        select(a, b, e.isControlKey());
        lastSelected = listStore.getAt(last);
        listView.focusItem(index);
        // view.focusRow(index);
      } else if (isSelected(sel) && e.isControlKey()) {
        doDeselect(Arrays.asList(sel), false);
      } else {
        doSelect(Arrays.asList(sel), e.isControlKey(), false);
        listView.focusItem(e.getIndex());
        // view.focusRow(e.rowIndex);
      }
    }
  }
Example #2
0
  public SelectMany05Bean() {

    HobbitBean[] hobbits = {
      new HobbitBean("Bilbo", "Ring Finder"),
      new HobbitBean("Frodo", "Ring Bearer"),
      new HobbitBean("Merry", "Trouble Maker"),
      new HobbitBean("Pippin", "Trouble Maker")
    };

    Set<SelectItem> items = new LinkedHashSet<SelectItem>();
    for (HobbitBean hobbit : hobbits) {
      items.add(new SelectItem(hobbit.getName()));
    }
    hobbitCollection = new TreeSet<HobbitBean>();
    hobbitCollection.addAll(Arrays.asList(hobbits));
    possibleValues = Collections.unmodifiableSet(items);
    initialSortedSetValues = new TreeSet<String>(Collections.reverseOrder());
    initialSortedSetValues.add("Pippin");
    initialSortedSetValues.add("Frodo");
    initialCollectionValues = new LinkedHashSet<String>(2);
    initialCollectionValues.add("Bilbo");
    initialCollectionValues.add("Merry");
    initialSetValues = new CopyOnWriteArraySet<String>(); // not Cloneable
    initialSetValues.add("Frodo");
    initialListValues = new Vector<String>();
    initialListValues.add("Bilbo");
    initialListValues.add("Pippin");
    initialListValues.add("Merry");
    hobbitDataModel =
        new ListDataModel<HobbitBean>(new ArrayList<HobbitBean>(Arrays.asList(hobbits)));
  }
  @Override
  public void setUp() throws Exception {
    solo = new Solo(getInstrumentation(), getActivity());

    FlashcardActivityState state = FlashcardActivityState_.getInstance_(solo.getCurrentActivity());
    state.setBox(1);

    DatabaseOpenHelper openHelper = new DatabaseOpenHelper(solo.getCurrentActivity());
    cardDao = openHelper.getDao(Card.class);
    cardDao.queryForAll().size();
    List<List<String>> cards =
        Arrays.asList(
            Arrays.asList("111", "AAA", "1"),
            Arrays.asList("222", "BBB", "1"),
            Arrays.asList("333", "CCC", "1"),
            Arrays.asList("444", "DDD", "1"),
            Arrays.asList("555", "EEE", "1"),
            Arrays.asList("666", "FFF", "2"),
            Arrays.asList("777", "GGG", "2"),
            Arrays.asList("888", "HHH", "3"),
            Arrays.asList("999", "III", "3"));
    for (List<String> card : cards) {
      createCardForTest(card.get(0), card.get(1), Integer.valueOf(card.get(2)));
    }
  }
  @Test
  public void testSimpleFilter() throws Exception {
    final InetAddress oneNinetyTwo = addr("192.168.0.1");

    final List<InetAddress> addresses = Arrays.asList(oneNinetyTwo);
    m_filterDao.setActiveIPAddressList(addresses);

    final OnmsNode node = new OnmsNode(null, "foo");
    node.setId(1);
    node.setForeignSource("foo");
    node.setForeignId("bar");
    node.setSysObjectId(".1.2.3.4.5");
    final OnmsIpInterface iface = new OnmsIpInterface(oneNinetyTwo, node);
    final OnmsServiceType serviceType = new OnmsServiceType("SNMP");
    final OnmsMonitoredService service = new OnmsMonitoredService(iface, serviceType);
    m_monitoredServiceDao.setMatching(Arrays.asList(service));

    final Response response = m_configResource.getAgentsJson("example1", "SNMP");
    assertEquals(200, response.getStatus());
    final Object entity = response.getEntity();
    assertNotNull(entity);
    assertTrue(entity instanceof GenericEntity<?>);
    @SuppressWarnings("unchecked")
    final List<AgentResponse> agentResponses =
        (List<AgentResponse>) ((GenericEntity<?>) entity).getEntity();
    System.err.println(agentResponses);
    assertEquals(1, agentResponses.size());
    assertEquals(oneNinetyTwo, agentResponses.get(0).getAddress());
    assertEquals(1161, agentResponses.get(0).getPort().intValue());
    assertEquals(".1.2.3.4.5", agentResponses.get(0).getParameters().get("sysObjectId"));
    assertEquals("1", agentResponses.get(0).getParameters().get("nodeId"));
    assertEquals("foo", agentResponses.get(0).getParameters().get("foreignSource"));
    assertEquals("bar", agentResponses.get(0).getParameters().get("foreignId"));
  }
Example #5
0
 static void validateColumnPath(String tablename, ColumnPath column_path)
     throws InvalidRequestException {
   validateTable(tablename);
   ColumnFamilyType cfType = validateColumnFamily(tablename, column_path.column_family);
   if (cfType == ColumnFamilyType.Standard) {
     if (column_path.super_column != null) {
       throw new InvalidRequestException(
           "supercolumn parameter is invalid for standard CF " + column_path.column_family);
     }
     if (column_path.column == null) {
       throw new InvalidRequestException(
           "column parameter is not optional for standard CF " + column_path.column_family);
     }
   } else {
     if (column_path.super_column == null)
       throw new InvalidRequestException(
           "supercolumn parameter is not optional for super CF " + column_path.column_family);
   }
   if (column_path.column != null) {
     validateColumns(
         tablename,
         column_path.column_family,
         column_path.super_column,
         Arrays.asList(column_path.column));
   }
   if (column_path.super_column != null) {
     validateColumns(
         tablename, column_path.column_family, null, Arrays.asList(column_path.super_column));
   }
 }
Example #6
0
  @Test
  public void testClientWildcard() throws Exception {
    BaseClientDetails theclient =
        new BaseClientDetails(
            "client",
            "zones",
            "zones.*.admin",
            "authorization_code, password",
            "scim.read, scim.write",
            "http://localhost:8080/uaa");
    theclient.setAutoApproveScopes(Arrays.asList("zones.*.admin"));
    Map<String, ? extends ClientDetails> clientDetailsStore =
        Collections.singletonMap("client", theclient);

    clientDetailsService.setClientDetailsStore(clientDetailsStore);
    tokenServices.setClientDetailsService(clientDetailsService);

    authorizationRequest =
        new AuthorizationRequest("client", Collections.singleton("zones.myzone.admin"));
    authorizationRequest.setResourceIds(new HashSet<>(Arrays.asList("client", "zones")));
    authentication =
        new OAuth2Authentication(
            authorizationRequest.createOAuth2Request(),
            UaaAuthenticationTestFactory.getAuthentication(userId, userName, "olds@vmware.com"));

    accessToken = tokenServices.createAccessToken(authentication);

    endpoint.checkToken(accessToken.getValue());
  }