當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。