当前位置: 首页>>代码示例>>Java>>正文


Java List.retainAll方法代码示例

本文整理汇总了Java中java.util.List.retainAll方法的典型用法代码示例。如果您正苦于以下问题:Java List.retainAll方法的具体用法?Java List.retainAll怎么用?Java List.retainAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.List的用法示例。


在下文中一共展示了List.retainAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRibbonEnv

import java.util.List; //导入方法依赖的package包/类
private String getRibbonEnv() {
    String[] activeProfiles = env.getActiveProfiles();
    String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();

    if (displayOnActiveProfiles == null) {
        return null;
    }

    List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
    List<String> springBootProfiles = Arrays.asList(activeProfiles);
    ribbonProfiles.retainAll(springBootProfiles);

    if (ribbonProfiles.size() > 0) {
        return ribbonProfiles.get(0);
    }
    return null;
}
 
开发者ID:mraible,项目名称:devoxxus-jhipster-microservices-demo,代码行数:18,代码来源:ProfileInfoResource.java

示例2: getCommonParents

import java.util.List; //导入方法依赖的package包/类
public static ObjectNode getCommonParents(String urnOne, String urnTwo) {
  ObjectNode result = Json.newObject();

  // get lists of parents for both urns
  List<String> oneParents = getParents(urnOne);
  List<String> twoParents = getParents(urnOne);

  // create a list to hold just the common parents
  List<String> commonParents = new ArrayList<>(oneParents);

  // retainAll() leaves commonParents with just the values in both lists
  commonParents.retainAll(twoParents);
  if (commonParents != null && commonParents.size() > 0) {
    result.put("return_code", 200);
    result.put("common_parents", commonParents.toString());
  } else {
    result.put("return_code", 404);
    result.put("error_message", "No common parents found");
  }

  return result;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:23,代码来源:DatasetDao.java

示例3: purifyRecipients

import java.util.List; //导入方法依赖的package包/类
private String[] purifyRecipients(String[] addresses, YadaEmailContent yadaEmailContent) {
	// Se <validEmail> esiste, mando solo se l'email è nella lista
	List<String> validEmail = config.getValidDestinationEmails();
	if (validEmail!=null && !validEmail.isEmpty()) {
		List<String> recipients = new ArrayList<String>(Arrays.asList(addresses)); // Il doppio passaggio serve perchè asList è fixed size
		// Tengo solo quelli validi
		if (recipients.retainAll(validEmail)) {
			// Alcuni sono stati rimossi. Logghiamo quelli rimossi
			List<String> invalidEmails = new ArrayList<String>(Arrays.asList(addresses)); // Il doppio passaggio serve perchè asList è fixed size
			invalidEmails.removeAll(validEmail);
			for (String address : invalidEmails) {
				log.warn("Email not authorized in configuration (not in <validEmail>). Skipping message for '{}' from='{}' subject='{}' body='{}'",
					new Object[]{address, yadaEmailContent.from, yadaEmailContent.subject, yadaEmailContent.body});
			}
		}
		return recipients.toArray(new String[0]);
	} else {
		return addresses;
	}
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:21,代码来源:YadaEmailService.java

示例4: search

import java.util.List; //导入方法依赖的package包/类
/**
 * We are searching on a query string (on group name), or by user as member, or both.
 * If the user search is invoked, the boolean flag indicates if all parents of the group
 * are to be included in the result set
 */
@Override
public List<TLEGroup> search(String query, String userId, boolean allParents)
{
	if( Check.isEmpty(userId) )
	{
		return search(query);
	}
	else
	{
		List<TLEGroup> userGroups = getGroupsContainingUser(userId, allParents);
		if( Check.isEmpty(query) )
		{
			return userGroups;
		}
		else
		{
			List<TLEGroup> queryGroups = search(query);
			queryGroups.retainAll(userGroups);
			return queryGroups;
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:TLEGroupServiceImpl.java

示例5: getInterestedLoggersByEvent

import java.util.List; //导入方法依赖的package包/类
/**
 * Get those loggers interested in a given event.
 */
private Collection<AntLogger> getInterestedLoggersByEvent(AntEvent e) {
    File scriptLocation = e.getScriptLocation();
    String targetName = e.getTargetName();
    String taskName = e.getTaskName();
    int logLevel = e.getLogLevel();
    synchronized (this) { // #132945: <parallel> can deadlock if you block on event info here
        initInterestedLoggers();
        // Start with the smallest one and go down.
        interestedLoggersByVariousCriteria[0] = getInterestedLoggersByScript(scriptLocation);
        interestedLoggersByVariousCriteria[1] = getInterestedLoggersByTarget(targetName);
        interestedLoggersByVariousCriteria[2] = getInterestedLoggersByTask(taskName);
        interestedLoggersByVariousCriteria[3] = getInterestedLoggersByLevel(logLevel);
        Arrays.sort(interestedLoggersByVariousCriteria, INTERESTED_LOGGERS_SORTER);
        LOG.log(Level.FINEST, "getInterestedLoggersByVariousCriteria: event={0} loggers={1}", new Object[] {e, Arrays.asList(interestedLoggersByVariousCriteria)});
        // XXX could probably be even a bit more efficient by iterating on the fly...
        // and by skipping the sorting which is probably overkill for a small number of a loggers (or hardcode the sort)
        List<AntLogger> loggers = new LinkedList<AntLogger>(interestedLoggersByVariousCriteria[0]);
        for (int i = 1; i < 4; i++) {
            loggers.retainAll(interestedLoggersByVariousCriteria[i]);
        }
        LOG.log(Level.FINEST, "getInterestedLoggersByEvent: event={0} loggers={1}", new Object[] {e, loggers});
        return loggers;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:NbBuildLogger.java

示例6: topologicalSort

import java.util.List; //导入方法依赖的package包/类
private static <T> List<T> topologicalSort(Collection<T> c, Map<? super T, ? extends Collection<? extends T>> edges)
throws TopologicalSortException {
    Map<T,Boolean> finished = new HashMap<>();
    List<T> r = new ArrayList<>(Math.max(c.size(), 1));
    List<T> cRev = new ArrayList<>(c);
    Collections.reverse(cRev);

    Iterator<T> it = cRev.iterator();

    while (it.hasNext()) {
        List<T> cycle = visit(it.next(), edges, finished, r);

        if (cycle != null) {
            throw new TopologicalSortException("Cycle detected: " + cycle.toString());
        }
    }

    Collections.reverse(r);
    if (r.size() != c.size()) {
        r.retainAll(c);
    }

    return r;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SortSuiteModules.java

示例7: availableStrata

import java.util.List; //导入方法依赖的package包/类
@Override
public List<String> availableStrata() {
    List<String> mstrata = null;
    List<String> strata = null;
    for (ReferenceType t : types) {
        List<String> tstrata = t.availableStrata();
        if (strata == null) {
            strata = tstrata;
        } else if (!tstrata.containsAll(strata)) {
            if (mstrata == null) {
                mstrata = new ArrayList<String>(strata);
            }
            mstrata.retainAll(tstrata);
        }
    }
    if (mstrata != null) {
        return mstrata;
    } else {
        return strata;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:EvaluatorVisitor.java

示例8: getRibbonEnv

import java.util.List; //导入方法依赖的package包/类
private String getRibbonEnv(String[] activeProfiles) {
    String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();

    if (displayOnActiveProfiles == null) {
        return null;
    }

    List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
    List<String> springBootProfiles = Arrays.asList(activeProfiles);
    ribbonProfiles.retainAll(springBootProfiles);

    if (ribbonProfiles.size() > 0) {
        return ribbonProfiles.get(0);
    }
    return null;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:17,代码来源:ProfileInfoResource.java

示例9: getRibbonEnv

import java.util.List; //导入方法依赖的package包/类
private String getRibbonEnv(String[] activeProfiles) {
    String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();
    if (displayOnActiveProfiles == null) {
        return null;
    }
    List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
    List<String> springBootProfiles = Arrays.asList(activeProfiles);
    ribbonProfiles.retainAll(springBootProfiles);
    if (!ribbonProfiles.isEmpty()) {
        return ribbonProfiles.get(0);
    }
    return null;
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:14,代码来源:_ProfileInfoService.java

示例10: intersect

import java.util.List; //导入方法依赖的package包/类
/**
 * This method returns a new ArrayList which is the intersection of the two List parameters, based on {@link Object#equals(Object) equality}
 * of their elements.
 * The intersection list will contain elements in the order they have in list1 and any references in the resultant list will be
 * to elements within list1 also.
 * 
 * @return a new ArrayList whose values represent the intersection of the two Lists.
 */
public static <T> List<T> intersect(List<? extends T> list1, List<? extends T> list2)
{
    if (list1 == null || list1.isEmpty() || list2 == null || list2.isEmpty())
    {
        return Collections.emptyList();
    }
    
    List<T> result = new ArrayList<T>();
    result.addAll(list1);
    
    result.retainAll(list2);
    
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:23,代码来源:CollectionUtils.java

示例11: reverseSourceRootsInOrder

import java.util.List; //导入方法依赖的package包/类
private List<URL> reverseSourceRootsInOrder(CompilationInfo info, URL thisSourceRoot, FileObject thisSourceRootFO, Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps, Map<URL, List<URL>> rootPeers, boolean interactive) {
    if (reverseSourceRootsInOrderOverride != null) {
        return reverseSourceRootsInOrderOverride;
    }

    final Set<URL> sourceRootsSet = new HashSet<>();

    if (sourceDeps.containsKey(thisSourceRoot)) {
        sourceRootsSet.addAll(findReverseSourceRoots(thisSourceRoot, sourceDeps, rootPeers, info.getFileObject()));
    }
    for (URL binary : findBinaryRootsForSourceRoot(thisSourceRootFO, binaryDeps)) {
        final List<URL> deps = binaryDeps.get(binary);
        if (deps != null) {
            sourceRootsSet.addAll(deps);
        }
    }
    List<URL> sourceRoots;
    try {
        sourceRoots = new LinkedList<URL>(Utilities.topologicalSort(sourceDeps.keySet(), sourceDeps));
    } catch (TopologicalSortException ex) {
        if (interactive) {
            Exceptions.attachLocalizedMessage(ex,NbBundle.getMessage(GoToImplementation.class, "ERR_CycleInDependencies"));
            Exceptions.printStackTrace(ex);
        } else {
            LOG.log(Level.FINE, null, ex);
        }
        return null;
    }

    sourceRoots.retainAll(sourceRootsSet);

    Collections.reverse(sourceRoots);

    return sourceRoots;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ComputeOverriders.java

示例12: getDescriptorDefinedUris

import java.util.List; //导入方法依赖的package包/类
public List<String> getDescriptorDefinedUris(DeployedMtaModule deployedModule) {
    if (deployedModule == null) {
        return Collections.emptyList();
    }
    List<String> allUris = getUrisWithoutScheme(deployedModule);
    List<String> descriptorDefinedUris = getDescriptorDefinedUrisOrDefault(deployedModule, allUris);
    descriptorDefinedUris.retainAll(allUris);
    return descriptorDefinedUris;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:10,代码来源:UrisClassifier.java

示例13: getJoinByData

import java.util.List; //导入方法依赖的package包/类
private boolean getJoinByData() {
	logger.debug("Searching for a join by matching data..");
	try {
		ArrayList<String> l = Lists.newArrayList();
		ArrayList<String> r = Lists.newArrayList();
		for(int i =1; i<=left.getMetaData().getColumnCount(); i++){
			String lname = left.getMetaData().getColumnName(i);
			List<String> lvalues = Lists.newArrayList();
			left.beforeFirst();
			while(left.next()){
				lvalues.add(left.getString(i));
			}

			for(int j =1; j<=right.getMetaData().getColumnCount(); j++){
				String rname = right.getMetaData().getColumnName(j);
				List<String> rvalues = Lists.newArrayList();
				right.beforeFirst();
				while(right.next()){
					rvalues.add(right.getString(j));
				}
				List<String> rinter = Lists.newArrayList(rvalues);
				boolean thereAreSomeNoMatches = rinter.retainAll(lvalues);
				if(thereAreSomeNoMatches){
					double x = rinter.size()/(rvalues.size()*1.000);
					if(x > 0.1){
						l.add(lname);
						r.add(rname);
						break;
					}
				}else{
					l.add(lname);
					r.add(rname);
					break;
				}
			}
			if(l.size()>0) break;
		}
		if(l.size()>0){
			setCardinality(l,r);
			setFormula(l,r);
			return true;
		}else{
			return false;
		}

	} catch (SQLException e) {
		logger.error("Somethign went wrong while searching for a join"
				+ " between " + jd.getLeft() + " and " + jd.getRight() +"\n"+e.getMessage());
		return false;
	}

}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:53,代码来源:JoinDetector.java

示例14: getEnableableCiphers

import java.util.List; //导入方法依赖的package包/类
@Override
public String[] getEnableableCiphers(SSLContext context) {
    String requestedCiphersStr = endpoint.getCiphers();

    if (ALLOW_ALL_SUPPORTED_CIPHERS.equals(requestedCiphersStr)) {
        return context.getSupportedSSLParameters().getCipherSuites();
    }
    if ((requestedCiphersStr == null)
            || (requestedCiphersStr.trim().length() == 0)) {
        return defaultServerCipherSuites;
    }

    List<String> requestedCiphers = new ArrayList<String>();
    for (String rc : requestedCiphersStr.split(",")) {
        final String cipher = rc.trim();
        if (cipher.length() > 0) {
            requestedCiphers.add(cipher);
        }
    }
    if (requestedCiphers.isEmpty()) {
        return defaultServerCipherSuites;
    }
    List<String> ciphers = new ArrayList<String>(requestedCiphers);
    String[] supportedCipherSuiteArray = context.getSupportedSSLParameters().getCipherSuites();
    // The IBM JRE will accept cipher suites names SSL_xxx or TLS_xxx but
    // only returns the SSL_xxx form for supported cipher suites. Therefore
    // need to filter the requested cipher suites using both forms with an
    // IBM JRE.
    List<String> supportedCipherSuiteList;
    if (JreVendor.IS_IBM_JVM) {
        supportedCipherSuiteList = new ArrayList<String>(supportedCipherSuiteArray.length * 2);
        for (String name : supportedCipherSuiteArray) {
            supportedCipherSuiteList.add(name);
            if (name.startsWith("SSL")) {
                supportedCipherSuiteList.add("TLS" + name.substring(3));
            }
        }
    } else {
        supportedCipherSuiteList = Arrays.asList(supportedCipherSuiteArray);
    }
    ciphers.retainAll(supportedCipherSuiteList);

    if (ciphers.isEmpty()) {
        log.warn(sm.getString("jsse.requested_ciphers_not_supported",
                requestedCiphersStr));
    }
    if (log.isDebugEnabled()) {
        log.debug(sm.getString("jsse.enableable_ciphers", ciphers));
        if (ciphers.size() != requestedCiphers.size()) {
            List<String> skipped = new ArrayList<String>(requestedCiphers);
            skipped.removeAll(ciphers);
            log.debug(sm.getString("jsse.unsupported_ciphers", skipped));
        }
    }

    return ciphers.toArray(new String[ciphers.size()]);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:58,代码来源:JSSESocketFactory.java

示例15: getUsedTypeVars

import java.util.List; //导入方法依赖的package包/类
public List<TreePathHandle> getUsedTypeVars() {
    List<TreePathHandle> ll = new ArrayList<TreePathHandle>(getTypeVarDefs());
    ll.retainAll(usedTypeVariables);
    return ll;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ScanStatement.java


注:本文中的java.util.List.retainAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。