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


Java List.contains方法代码示例

本文整理汇总了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));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:FileSystem.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BasicTestForImport.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MavenSourcesImpl.java

示例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);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:ThriftRpcClient.java

示例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;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:33,代码来源:ConfigSearchService.java

示例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;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:38,代码来源:CommonModel.java

示例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());
    }
  };
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:13,代码来源:CompoundHashTest.java

示例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;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:33,代码来源:PolicyManager.java

示例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;
}
 
开发者ID:wongcain,项目名称:okuki,代码行数:40,代码来源:PlaceScoper.java

示例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;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:41,代码来源:RegistrationFormLocalServiceImpl.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:ChronoZonedDateTimeImpl.java

示例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;
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:34,代码来源:Tpc.java

示例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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:36,代码来源:mxGraphStructure.java

示例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();
	}
}
 
开发者ID:Edward7Zhang,项目名称:SuperMarketManageSystem,代码行数:34,代码来源:JinHuoTuiHuo.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AbstractSvnTestCase.java


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