當前位置: 首頁>>代碼示例>>Java>>正文


Java List.add方法代碼示例

本文整理匯總了Java中java.util.List.add方法的典型用法代碼示例。如果您正苦於以下問題:Java List.add方法的具體用法?Java List.add怎麽用?Java List.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onViewCreated

import java.util.List; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    final List<Object> items = new ArrayList<>();

    for (int i = 0; i < ITEM_COUNT; ++i) {
        items.add(new Object());
    }


    //setup materialviewpager

    if (GRID_LAYOUT) {
        mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    } else {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    mRecyclerView.setHasFixedSize(true);

    //Use this now
    mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
    mRecyclerView.setAdapter(new TestRecyclerViewAdapter(items));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:RecyclerViewFragment.java

示例2: buildCriterion

import java.util.List; //導入方法依賴的package包/類
private void buildCriterion(And and,ConditionTreeNode node){
	if(node==null)return;
	List<ConditionTreeNode> nodes=new ArrayList<ConditionTreeNode>();
	nodes.add(node);
	VariableTreeNode varNode=null;
	TreeNode parentNode=node.getParentNode();
	while(parentNode!=null){
		if(parentNode instanceof VariableTreeNode){
			varNode=(VariableTreeNode)parentNode;
			buildCriterion(and,(ConditionTreeNode)parentNode.getParentNode());
			break;
		}else if(parentNode instanceof ConditionTreeNode){
			ConditionTreeNode parentConditionTreeNode=(ConditionTreeNode)parentNode;
			nodes.add(parentConditionTreeNode);
			parentNode=parentConditionTreeNode.getParentNode();
		}
	}
	if(varNode==null){
		throw new RuleException("Decision tree is invalid.");
	}
	for(ConditionTreeNode cn:nodes){
		and.addCriterion(buildCriteria(cn,varNode));
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:25,代碼來源:DecisionTreeRulesBuilder.java

示例3: translateLinesParallel

import java.util.List; //導入方法依賴的package包/類
/**
 *
 * @param lines lines to be translated
 * @param lang src-dest languages
 * @return a new collection containing the original words and their translation
 */
public static List<Line> translateLinesParallel(List<Line> lines, String lang)  {

    List<Line> translatedLines = new ArrayList<>(lines.size());
    final ExecutorService pool = Executors.newFixedThreadPool(NB_PROCS * FACTOR);
    final ExecutorCompletionService<Line> completionService = new ExecutorCompletionService<>(pool);
    for (final Line l : lines) {
        completionService.submit(() -> l.setTranslation(
                Word.getTranslation(
                        URLEncoder.encode(l.getText(), Constants.DEFAULT_ENCODING),
                        lang)));
    }

    for (int i = 0; i < lines.size(); i++) {
        try {
            final Future<Line> future = completionService.take();
            final Line translation = future.get();
            translatedLines.add(translation);

        } catch (InterruptedException | ExecutionException e) {
        }
    }

    pool.shutdown();
    return translatedLines;
}
 
開發者ID:plowsec,項目名稱:sub2cards,代碼行數:32,代碼來源:Line.java

示例4: afterPropertiesSet

import java.util.List; //導入方法依賴的package包/類
public void afterPropertiesSet() throws Exception {
    Assert.notNull(loader, "no resourceLoader");

    if (locationNames != null) {
        for (int i = 0; i < locationNames.length; i++) {
            locationNames[i] = resolveSystemPropertyPlaceholders(locationNames[i]);
        }
    }

    if (locationNames != null) {
        List<Resource> resources = new ArrayList<Resource>(locationNames.length);

        for (String location : locationNames) {
            location = trimToNull(location);

            if (location != null) {
                resources.add(loader.getResource(location));
            }
        }

        super.setLocations(resources.toArray(new Resource[resources.size()]));
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:24,代碼來源:PropertyPlaceholderConfigurer.java

示例5: main

import java.util.List; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
  if (args.length == 0) {
    showUsage();
    return;
  }

  switch (args[0]) {
    case "login":
      System.out.print("Paste the client ID JSON from the Google API console:");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String clientSecret = br.readLine();
      List<String> scopes = new ArrayList<String>();
      scopes.add(YouTubeScopes.YOUTUBE_FORCE_SSL);
      scopes.add(YouTubeScopes.YOUTUBE);
      Auth.authorize(scopes, clientSecret, YouTubeChat.MODID);
      break;
    case "logout":
      Auth.clearCredentials();
      break;
    default:
      showUsage();
  }
}
 
開發者ID:youtube,項目名稱:youtube-chat-for-minecraft,代碼行數:24,代碼來源:Main.java

示例6: addProblems

import java.util.List; //導入方法依賴的package包/類
@Override
public void addProblems(List<String> curInfo) {
    super.addProblems(curInfo);
    if (te.getEfficiency() < 100) {
        curInfo.add(I18n.format("gui.tab.problems.advancedAirCompressor.efficiency", te.getEfficiency() + "%%"));
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:GuiAdvancedLiquidCompressor.java

示例7: getPhotos

import java.util.List; //導入方法依賴的package包/類
private List<Map<String, Object>> getPhotos() {

        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("photo", R.drawable.sign_in_background2);

        map = new HashMap<String, Object>();
        map.put("photo", R.drawable.sign_in_background);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("photo", R.drawable.sign_in_background2);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("photo", R.drawable.sign_in_background);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("photo", R.drawable.sign_in_background2);
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("photo", R.drawable.background3);
        list.add(map);

        return list;
    }
 
開發者ID:sherlockchou86,項目名稱:yphoto,代碼行數:30,代碼來源:StatusDetailView.java

示例8: toList

import java.util.List; //導入方法依賴的package包/類
/**
 * Adds 'objects' that satisfies 'filter' to 'list'.
 * @param <T>
 * @param objects
 * @param list
 * @param filter
 */
public static <T> void toList(T[] objects, List<T> list, ObjectFilter filter) {
	if (filter == null) {
		toList(objects, list);
		return;
	}
	if (objects == null) return;
	if (list == null) return;		
	for (T obj : objects) {			
		if (filter.accept(obj)) {
			list.add(obj);
		}
	}
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:21,代碼來源:MyCollections.java

示例9: getUserRoles

import java.util.List; //導入方法依賴的package包/類
/**
 * Get list of roles which the new user can be.
 * 
 * @return list with user's roles of the selected user
 * @throws ObjectNotFoundException
 * @throws OperationNotPermittedException
 */
private List<UserRole> getUserRoles() throws ObjectNotFoundException,
        OperationNotPermittedException {

    List<UserRole> result = new ArrayList<>();
    List<UserRoleType> availableRoles = getIdentityService()
            .getAvailableUserRoles(getIdentityService().getCurrentUserDetails());
    Set<UserRoleType> selectedRoles = new HashSet<>();
    if (userRolesForNewUser != null) {
        for (UserRole role : userRolesForNewUser) {
            if (role.isSelected()) {
                selectedRoles.add(role.getUserRoleType());
            }
        }
    }

    for (UserRoleType availableRole : availableRoles) {
        UserRole roleObj = new UserRole();
        roleObj.setUserRoleType(availableRole);
        if (selectedRoles.contains(availableRole)) {
            roleObj.setSelected(true);
        } else {
            roleObj.setSelected(false);
        }
        result.add(roleObj);
    }
    return result;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:35,代碼來源:UserImportBean.java

示例10: toChoices

import java.util.List; //導入方法依賴的package包/類
@Override
public Collection<UserFacade> toChoices(Collection<String> ids) {
	List<UserFacade> users = Lists.newArrayList();
	CacheManager cacheManager = GitPlex.getInstance(CacheManager.class);
	for (String each : ids) {
		Long id = Long.valueOf(each);
		users.add(cacheManager.getUser(id));
	}

	return users;
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:12,代碼來源:AbstractUserChoiceProvider.java

示例11: KeyedValues

import java.util.List; //導入方法依賴的package包/類
/**
   * Performs a deep copy on <i>other</i>.
   */
  public KeyedValues(KeyedValues other) {
    if (other.isSetKey()) {
      this.key = org.apache.thrift.TBaseHelper.copyBinary(other.key);
;
    }
    if (other.isSetValues()) {
      List<VersionedValue> __this__values = new ArrayList<VersionedValue>();
      for (VersionedValue other_element : other.values) {
        __this__values.add(new VersionedValue(other_element));
      }
      this.values = __this__values;
    }
  }
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:17,代碼來源:KeyedValues.java

示例12: marshall

import java.util.List; //導入方法依賴的package包/類
@Override
public AttributeValue marshall(Object obj) {
    @SuppressWarnings("unchecked")
    Set<UUID> uuids = (Set<UUID>) obj;

    List<String> strings = new ArrayList<String>(uuids.size());
    for (UUID uuid : uuids) {
        strings.add(uuid.toString());
    }

    return AttributeValue.builder().ss(strings).build();
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:13,代碼來源:UuidSetToStringSetMarshaller.java

示例13: hashCode

import java.util.List; //導入方法依賴的package包/類
@Override
public int hashCode() {
  List<Object> list = new ArrayList<Object>();

  boolean present_msg = true && (isSetMsg());
  list.add(present_msg);
  if (present_msg)
    list.add(msg);

  return list.hashCode();
}
 
開發者ID:somewhereMrli,項目名稱:albedo-thrift,代碼行數:12,代碼來源:EchoSerivce.java

示例14: getCreateTablesSQL

import java.util.List; //導入方法依賴的package包/類
@Override
protected List<String> getCreateTablesSQL() {
    List<String> sqlStatements = new ArrayList<>();
    sqlStatements.add(CREATE_SETTINGS_TABLE);
    sqlStatements.add(CREATE_HEADERS_TABLE);
    sqlStatements.add(CREATE_UNDOABLE_TABLE);
    sqlStatements.add(CREATE_OPEN_OUTPUT_TABLE);
    return sqlStatements;
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:10,代碼來源:MySQLFullPrunedBlockStore.java

示例15: testRemoteInputPort

import java.util.List; //導入方法依賴的package包/類
@Test
public void testRemoteInputPort() {
    final String componentType = "Remote Input Port";
    final String transitUri = "http://0.example.com:8080/nifi-api/data-transfer/input-ports/port-guid/transactions/tx-guid/flow-files";
    final ProvenanceEventRecord sendEvent = Mockito.mock(ProvenanceEventRecord.class);
    when(sendEvent.getEventId()).thenReturn(123L);
    when(sendEvent.getComponentId()).thenReturn("port-guid");
    when(sendEvent.getFlowFileUuid()).thenReturn("file-guid");
    when(sendEvent.getComponentType()).thenReturn(componentType);
    when(sendEvent.getTransitUri()).thenReturn(transitUri);
    when(sendEvent.getEventType()).thenReturn(ProvenanceEventType.SEND);

    final ProvenanceEventRecord createEvent = Mockito.mock(ProvenanceEventRecord.class);
    when(createEvent.getEventId()).thenReturn(456L);
    when(createEvent.getComponentId()).thenReturn("processor-guid");
    when(createEvent.getComponentType()).thenReturn("GenerateFlowFile");
    when(createEvent.getEventType()).thenReturn(ProvenanceEventType.CREATE);

    final ClusterResolvers clusterResolvers = Mockito.mock(ClusterResolvers.class);
    when(clusterResolvers.fromHostname(matches(".+\\.example\\.com"))).thenReturn("cluster1");

    final List<ConnectionStatus> connections = new ArrayList<>();
    final ConnectionStatus connection = new ConnectionStatus();
    connection.setDestinationId("port-guid");
    connection.setDestinationName("inputPortA");
    connections.add(connection);

    final AnalysisContext context = Mockito.mock(AnalysisContext.class);
    when(context.getClusterResolver()).thenReturn(clusterResolvers);
    when(context.findConnectionTo(matches("port-guid"))).thenReturn(connections);
    when(context.getProvenanceEvent(eq(456L))).thenReturn(createEvent);

    final ComputeLineageResult lineage = Mockito.mock(ComputeLineageResult.class);
    when(context.queryLineage(eq(123L))).thenReturn(lineage);

    final LineageNode sendEventNode = createLineageNode(PROVENANCE_EVENT_NODE, "123");
    final LineageNode flowFileNode = createLineageNode(FLOWFILE_NODE, "flowfile-uuid-1234");
    final LineageNode createEventNode = createLineageNode(PROVENANCE_EVENT_NODE, "456");

    final List<LineageEdge> edges = new ArrayList<>();
    edges.add(createLineageEdge(createEventNode, flowFileNode));
    edges.add(createLineageEdge(flowFileNode, sendEventNode));
    when(lineage.getEdges()).thenReturn(edges);

    final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, sendEvent.getEventType());
    assertNotNull(analyzer);

    final DataSetRefs refs = analyzer.analyze(context, sendEvent);
    assertEquals(0, refs.getInputs().size());
    assertEquals(1, refs.getOutputs().size());
    assertEquals(1, refs.getComponentIds().size());
    // Should report connected componentId.
    assertTrue(refs.getComponentIds().contains("processor-guid"));

    Referenceable ref = refs.getOutputs().iterator().next();
    assertEquals(TYPE_NIFI_INPUT_PORT, ref.getTypeName());
    assertEquals("inputPortA", ref.get(ATTR_NAME));
    assertEquals("file-guid", ref.get(ATTR_QUALIFIED_NAME));
}
 
開發者ID:bcgov,項目名稱:nifi-atlas,代碼行數:60,代碼來源:TestNiFiRemotePort.java


注:本文中的java.util.List.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。