本文整理匯總了Java中java.util.List.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java List.contains方法的具體用法?Java List.contains怎麽用?Java List.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.List
的用法示例。
在下文中一共展示了List.contains方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkAccessPermissions
import java.util.List; //導入方法依賴的package包/類
/**
* This method provides the default implementation of
* {@link #access(Path, FsAction)}.
*
* @param stat FileStatus to check
* @param mode type of access to check
* @throws IOException for any error
*/
@InterfaceAudience.Private
static void checkAccessPermissions(FileStatus stat, FsAction mode)
throws IOException {
FsPermission perm = stat.getPermission();
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
String user = ugi.getShortUserName();
List<String> groups = Arrays.asList(ugi.getGroupNames());
if (user.equals(stat.getOwner())) {
if (perm.getUserAction().implies(mode)) {
return;
}
} else if (groups.contains(stat.getGroup())) {
if (perm.getGroupAction().implies(mode)) {
return;
}
} else {
if (perm.getOtherAction().implies(mode)) {
return;
}
}
throw new AccessControlException(String.format(
"Permission denied: user=%s, path=\"%s\":%s:%s:%s%s", user, stat.getPath(),
stat.getOwner(), stat.getGroup(), stat.isDirectory() ? "d" : "-", perm));
}
示例2: assertProperty
import java.util.List; //導入方法依賴的package包/類
public void assertProperty(final String propertyName, final String expected) throws IOException, ClassNotFoundException {
Result support = readSystemOption(false);
List parsedPropNames = Arrays.asList(support.getPropertyNames());
String parsedPropertyName = null;
boolean isFakeName = !parsedPropNames.contains(propertyName);
if (isFakeName) {
assertTrue(propertyName+" (alias: "+parsedPropertyName + ") not found in: " + parsedPropNames,parsedPropNames.contains(parsedPropertyName));
} else {
parsedPropertyName = propertyName;
}
assertNotNull(parsedPropertyName);
Class expectedClass = null;
String actual = support.getProperty(parsedPropertyName);
if (actual == null) {
assertNull(expectedClass);
assertEquals(expected, actual);
} else {
assertEquals(expected, actual);
}
}
示例3: checkGeneratedGroupsCache
import java.util.List; //導入方法依賴的package包/類
private boolean checkGeneratedGroupsCache() {
boolean changed = false;
List<File> checked = new ArrayList<File>();
for (boolean test : new boolean[] {false, true}) {
for (URI u : project().getGeneratedSourceRoots(test)) {
File file = FileUtil.normalizeFile(Utilities.toFile(u));
FileObject folder = FileUtil.toFileObject(file);
changed |= checkGeneratedGroupCache(folder, file, file.getName(), test);
checked.add(file);
}
}
Set<File> currs = new HashSet<File>();
currs.addAll(genSrcGroup.keySet());
for (File curr : currs) {
if (!checked.contains(curr)) {
genSrcGroup.remove(curr);
changed = true;
}
}
return changed;
}
示例4: createSSLSocket
import java.util.List; //導入方法依賴的package包/類
private static TSocket createSSLSocket(SSLSocketFactory factory, String host,
int port, int timeout, List<String> excludeProtocols)
throws FlumeException {
try {
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
socket.setSoTimeout(timeout);
List<String> enabledProtocols = new ArrayList<String>();
for (String protocol : socket.getEnabledProtocols()) {
if (!excludeProtocols.contains(protocol)) {
enabledProtocols.add(protocol);
}
}
socket.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
return new TSocket(socket);
} catch (Exception e) {
throw new FlumeException("Could not connect to " + host + " on port " + port, e);
}
}
示例5: filterByTag
import java.util.List; //導入方法依賴的package包/類
/**
* 使用標簽來過濾配置項
*
* @param configItemList
* @param tagIdList
* @return
*/
private List<ConfigItem> filterByTag(List<ConfigItem> configItemList, List<Integer> tagIdList) {
// 未限定
if (tagIdList == null || tagIdList.isEmpty()) {
return configItemList;
}
List<ConfigItem> filteredConfigItemList = new ArrayList<>();
for (ConfigItem configItem : configItemList) {
if (StringUtils.isNotEmpty(configItem.getTags())) {
boolean tagged = false;
for (String tagId : StringUtils.split(configItem.getTags(), ",")) {
if (tagIdList.contains(Integer.valueOf(tagId))) {
tagged = true;
break;
}
}
if (tagged) {
filteredConfigItemList.add(configItem);
}
}
}
return filteredConfigItemList;
}
示例6: getUniqueTransitionModeName
import java.util.List; //導入方法依賴的package包/類
/**
* Returns given name if a mode with the same name does not exist or makes it unique
* for a transition
* @param key station key
* @param name mode name
* @return unique name
*/
protected String getUniqueTransitionModeName(Object key, String name) {
// Map of all unique names with their first users
List<String> names = getAllTransitionModeNames(key);
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例7: splitAtPaths
import java.util.List; //導入方法依賴的package包/類
private static CompoundHash.SplitStrategy splitAtPaths(String... paths) {
final List<Path> pathList = new ArrayList<>();
for (String path : paths) {
pathList.add(path(path));
}
return new CompoundHash.SplitStrategy() {
@Override
public boolean shouldSplit(CompoundHash.CompoundHashBuilder state) {
return pathList.contains(state.currentPath());
}
};
}
示例8: buildFunctionRoleIndex
import java.util.List; //導入方法依賴的package包/類
/** Builds the FunctionRoleIndex based on information aquired from the PolicyCache object.
* This supplies the information as a list of roles with function access. The build process
* transposes this mapping.
*/
private static Map<String, List<String>> buildFunctionRoleIndex() {
Map<String, List<String>> index = new HashMap<String, List<String>>();
// Get the role mappings
Map<String, List<String>> roleMap = PolicyCache.getRoleMap();
if (roleMap != null) {
// Loop through the role list and build the function list
for (Map.Entry<String, List<String>> me : roleMap.entrySet()) {
String role = me.getKey();
List<String> funcs = me.getValue();
for (String func : funcs) {
// Get the function list for this function
List<String> idxFunc = index.get(func);
if (idxFunc == null) {
// New function, create a list and entry for it...
idxFunc = new LinkedList<String>();
index.put(func, idxFunc);
}
// Add the role to this function list if not already there
// the uniquess check should be removed if uniqueness is inforced in
// the XML Policy file!.. For now, assume it is not
if (!idxFunc.contains(role))
idxFunc.add(role);
}
}
}
return index;
}
示例9: onPlace
import java.util.List; //導入方法依賴的package包/類
@Override
public void onPlace(Place place) {
// get current place hierarchy
List<Class<? extends Place>> prevHier = (currentPlace == null) ? new ArrayList<>() : currentPlace.getHierarchy();
// get new place hierarchy
List<Class<? extends Place>> newHier = place.getHierarchy();
// close previous place scope hierarchy starting at first place of difference
List<Class<? extends Place>> keysToClose = new ArrayList<>(prevHier);
keysToClose.removeAll(newHier);
for (Class<? extends Place> keyToClose : keysToClose) {
Toothpick.closeScope(keyToClose);
}
// open new scope hierarchy setting modules for newly opened scopes
for (Class<? extends Place> keyToOpen : newHier) {
List<Module> modules = new ArrayList<>();
if (!prevHier.contains(keyToOpen)) {
Scope parentScope = openParentScope(keyToOpen);
List<Class<? extends Module>> moduleClasses = getModuleClassesForPlaceScope(keyToOpen);
for (Class<? extends Module> moduleClass : moduleClasses) {
try {
modules.add(parentScope.getInstance(moduleClass));
} catch (Exception e) {
try {
modules.add(moduleClass.newInstance());
} catch (Exception e1) {
throw new RuntimeException("Unable to instatiate module: " + moduleClass, e1);
}
}
}
}
openPlaceScope(keyToOpen, modules.toArray(new Module[modules.size()]));
}
currentPlace = place;
}
示例10: getSplitIndex
import java.util.List; //導入方法依賴的package包/類
/**
* @param pattern
* @return
*/
protected static List<String> getSplitIndex(String pattern) {
List<String> splitIndexs = new ArrayList<String>();
int eliminateParenthesis = 0;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < pattern.length(); i++) {
Character c = pattern.charAt(i);
if (c.toString().equals(StringPool.OPEN_PARENTHESIS)) {
eliminateParenthesis += 1;
} else if (c.toString().equals(StringPool.CLOSE_PARENTHESIS)) {
eliminateParenthesis += -1;
}
if (eliminateParenthesis == 1
&& c.toString().equals(StringPool.OPEN_PARENTHESIS)) {
startIndex = i;
}
if (eliminateParenthesis == 0
&& c.toString().equals(StringPool.CLOSE_PARENTHESIS)) {
endIndex = i;
}
if (!splitIndexs.contains(startIndex + StringPool.DASH + endIndex)
&& startIndex < endIndex) {
splitIndexs.add(startIndex + StringPool.DASH + endIndex);
}
}
return splitIndexs;
}
示例11: ofBest
import java.util.List; //導入方法依賴的package包/類
/**
* Obtains an instance from a local date-time using the preferred offset if possible.
*
* @param localDateTime the local date-time, not null
* @param zone the zone identifier, not null
* @param preferredOffset the zone offset, null if no preference
* @return the zoned date-time, not null
*/
static <R extends ChronoLocalDate> ChronoZonedDateTime<R> ofBest(
ChronoLocalDateTimeImpl<R> localDateTime, ZoneId zone, ZoneOffset preferredOffset) {
Objects.requireNonNull(localDateTime, "localDateTime");
Objects.requireNonNull(zone, "zone");
if (zone instanceof ZoneOffset) {
return new ChronoZonedDateTimeImpl<>(localDateTime, (ZoneOffset) zone, zone);
}
ZoneRules rules = zone.getRules();
LocalDateTime isoLDT = LocalDateTime.from(localDateTime);
List<ZoneOffset> validOffsets = rules.getValidOffsets(isoLDT);
ZoneOffset offset;
if (validOffsets.size() == 1) {
offset = validOffsets.get(0);
} else if (validOffsets.size() == 0) {
ZoneOffsetTransition trans = rules.getTransition(isoLDT);
localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds());
offset = trans.getOffsetAfter();
} else {
if (preferredOffset != null && validOffsets.contains(preferredOffset)) {
offset = preferredOffset;
} else {
offset = validOffsets.get(0);
}
}
Objects.requireNonNull(offset, "offset"); // protect against bad ZoneRules
return new ChronoZonedDateTimeImpl<>(localDateTime, offset, zone);
}
示例12: asymmetricAbbreviationSimilarity
import java.util.List; //導入方法依賴的package包/類
private static double asymmetricAbbreviationSimilarity(String a, String b, List<String> otherTokens) {
// Joker card
if ("KEYWORD".equals(b) && Setting.KEYWORD_RELATIONSHIP.contains(a) && !otherTokens.contains(a)) return 0.95;
// Abbreviation to two letters (e.g. address -> ad)
if (a.length() == 2 && b.length() >= 2 && a.charAt(0) == b.charAt(0) && a.charAt(1) == b.charAt(1)) {
return 0.95; // We penalize that a bit
}
// Another abbreviation to two letters (e.g. sector -> sc)
if (a.length() == 2 && b.length() >= 3 && a.charAt(0) == b.charAt(0) && a.charAt(1) == b.charAt(2)) {
return 0.95;
}
// Employ related terms (synonyms, hypernyms and hyponyms). Unfortunately, it is a hard match/mismatch
if (Setting.SYNONYM_PERSON.contains(a) && Setting.SYNONYM_PERSON.contains(b)) {
return 0.95;
}
if (Setting.SYNONYM_COUNTRY.contains(a) && Setting.SYNONYM_COUNTRY.contains(b)) {
return 0.95;
}
if (Setting.SYNONYM_PRODUCT.contains(a) && Setting.SYNONYM_PRODUCT.contains(b)) {
return 0.95;
}
if (Setting.SYNONYM_CITY.contains(a) && Setting.SYNONYM_CITY.contains(b)) {
return 0.95;
}
return 0.0;
}
示例13: getLowestDegreeVertex
import java.util.List; //導入方法依賴的package包/類
/**
* @param aGraph
* @param omitVertex vertices in this array will be omitted, set this parameter to null if you
* don't want this feature
* @return a vertex that has lowest degree, or one of those in case if there are more
*/
static public Object getLowestDegreeVertex(mxAnalysisGraph aGraph, Object[] omitVertex) {
Object[] vertices = aGraph.getChildVertices(aGraph.getGraph().getDefaultParent());
int vertexCount = vertices.length;
int lowestEdgeCount = Integer.MAX_VALUE;
Object bestVertex = null;
List<Object> omitList = null;
if (omitVertex != null) {
omitList = Arrays.asList(omitVertex);
}
for (int i = 0; i < vertexCount; i++) {
if (omitVertex == null || !omitList.contains(vertices[i])) {
int currEdgeCount = aGraph.getEdges(vertices[i], null, true, true, true, true).length;
if (currEdgeCount == 0) {
return vertices[i];
} else {
if (currEdgeCount < lowestEdgeCount) {
lowestEdgeCount = currEdgeCount;
bestVertex = vertices[i];
}
}
}
}
return bestVertex;
}
示例14: initSpBox
import java.util.List; //導入方法依賴的package包/類
private void initSpBox() {
List list = new ArrayList();
ResultSet set = Dao.query("select * from tb_kucun where "
+ "id in(select id from tb_spinfo where gysName='"
+ gys.getSelectedItem() + "')");
sp.removeAllItems();
sp.addItem(new TbKucun());
for (int i = 0; table != null && i < table.getRowCount(); i++) {
TbKucun tmpInfo = (TbKucun) table.getValueAt(i, 0);
if (tmpInfo != null && tmpInfo.getId() != null)
list.add(tmpInfo.getId());
}
try {
while (set.next()) {
TbKucun kucun = new TbKucun();
kucun.setId(set.getString("id").trim());
// ���������Դ���ͬ����Ʒ����Ʒ�������оͲ��ٰ�������Ʒ
if (list.contains(kucun.getId()))
continue;
kucun.setSpname(set.getString("spname").trim());
kucun.setCd(set.getString("cd").trim());
kucun.setJc(set.getString("jc").trim());
kucun.setDw(set.getString("dw").trim());
kucun.setGg(set.getString("gg").trim());
kucun.setBz(set.getString("bz").trim());
kucun.setDj(Double.valueOf(set.getString("dj").trim()));
kucun.setKcsl(Integer.valueOf(set.getString("kcsl").trim()));
sp.addItem(kucun);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
示例15: ignore
import java.util.List; //導入方法依賴的package包/類
protected void ignore(File file) throws SVNClientException {
File parent = file.getParentFile();
List patterns = getFullWorkingClient().getIgnoredPatterns(parent);
String path = file.getName();
if(!patterns.contains(path)) {
patterns.add(path);
}
getFullWorkingClient().setIgnoredPatterns(parent, patterns);
assertStatus(SVNStatusKind.IGNORED, file);
}