本文整理汇总了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));
}
示例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));
}
}
示例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;
}
示例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()]));
}
}
示例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();
}
}
示例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() + "%%"));
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
示例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));
}