本文整理汇总了Java中java.util.LinkedHashSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedHashSet.add方法的具体用法?Java LinkedHashSet.add怎么用?Java LinkedHashSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedHashSet
的用法示例。
在下文中一共展示了LinkedHashSet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getToolingImpl
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private ClassPath getToolingImpl() {
if (!gradleHomeDir.exists()) {
throw new IllegalArgumentException(String.format("The specified %s does not exist.", locationDisplayName));
}
if (!gradleHomeDir.isDirectory()) {
throw new IllegalArgumentException(String.format("The specified %s is not a directory.", locationDisplayName));
}
File libDir = new File(gradleHomeDir, "lib");
if (!libDir.isDirectory()) {
throw new IllegalArgumentException(String.format("The specified %s does not appear to contain a Gradle distribution.", locationDisplayName));
}
LinkedHashSet<File> files = new LinkedHashSet<File>();
for (File file : libDir.listFiles()) {
if (hasExtension(file, ".jar")) {
files.add(file);
}
}
return new DefaultClassPath(files);
}
示例2: generateKey
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Key for a cache object is built from all the known Authorities (which can change dynamically so they must all be
* used) the NodeRef ID and the permission reference itself. This gives a unique key for each permission test.
*/
Serializable generateKey(Set<String> auths, NodeRef nodeRef, PermissionReference perm, CacheType type)
{
LinkedHashSet<Serializable> key = new LinkedHashSet<Serializable>();
key.add(perm.toString());
// We will just have to key our dynamic sets by username. We wrap it so as not to be confused with a static set
if (auths instanceof AuthorityServiceImpl.UserAuthoritySet)
{
key.add((Serializable)Collections.singleton(((AuthorityServiceImpl.UserAuthoritySet)auths).getUsername()));
}
else
{
key.addAll(auths);
}
key.add(nodeRef);
// Ensure some concept of node version or transaction is included in the key so we can track without cache replication
NodeRef.Status nodeStatus = nodeService.getNodeStatus(nodeRef);
key.add(nodeStatus == null ? "null" : nodeStatus.getChangeTxnId());
key.add(type);
return key;
}
示例3: getResources
import java.util.LinkedHashSet; //导入方法依赖的package包/类
@Override
public Enumeration<URL> getResources(String name) throws IOException {
final LinkedHashSet<URL> resourceUrls = new LinkedHashSet<URL>();
for ( ClassLoader classLoader : individualClassLoaders ) {
final Enumeration<URL> urls = classLoader.getResources( name );
while ( urls.hasMoreElements() ) {
resourceUrls.add( urls.nextElement() );
}
}
return new Enumeration<URL>() {
final Iterator<URL> resourceUrlIterator = resourceUrls.iterator();
@Override
public boolean hasMoreElements() {
return resourceUrlIterator.hasNext();
}
@Override
public URL nextElement() {
return resourceUrlIterator.next();
}
};
}
示例4: setProjectedRowType
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private void setProjectedRowType(List<SchemaPath> projectedColumns){
if(projectedColumns != null){
LinkedHashSet<String> firstLevelPaths = new LinkedHashSet<>();
for(SchemaPath p : projectedColumns){
firstLevelPaths.add(p.getRootSegment().getNameSegment().getPath());
}
final RelDataTypeFactory factory = getCluster().getTypeFactory();
final FieldInfoBuilder builder = new FieldInfoBuilder(factory);
final Map<String, RelDataType> fields = new HashMap<>();
for(Field field : getBatchSchema()){
if(firstLevelPaths.contains(field.getName())){
fields.put(field.getName(), CompleteType.fromField(field).toCalciteType(factory));
}
}
Preconditions.checkArgument(firstLevelPaths.size() == fields.size(), "Projected column base size %d is not equal to outcome rowtype %d.", firstLevelPaths.size(), fields.size());
for(String path : firstLevelPaths){
builder.add(path, fields.get(path));
}
this.rowType = builder.build();
} else {
this.rowType = deriveRowType();
}
}
示例5: includeAdditionsSuperInterfaces2
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Adds all super-interfaces of pivot to acceptor except those listed in exclude
*
* @param acceptor
* list to add to
* @param exclude
* exclusion set
* @param pivot
* interface providing super-interfaces
*/
private <T extends TClassifier> void includeAdditionsSuperInterfaces2(LinkedHashSet<T> acceptor,
LinkedHashSet<T> exclude, T pivot, Class<T> castGuard) {
for (ParameterizedTypeRef superApiClassifier : pivot.getSuperClassifierRefs()) {
Type superApiDeclaredType = superApiClassifier.getDeclaredType();
if (castGuard.isAssignableFrom(superApiDeclaredType.getClass())) {
@SuppressWarnings("unchecked")
T superInterface = (T) superApiClassifier.getDeclaredType();
if (!exclude.contains(superInterface)) {
acceptor.add(superInterface);
}
} else {
// should we handle this or gracefully skip for broken models?
if (logger.isDebugEnabled()) {
logger.debug("Oopss ... Casting could not be performed Guard = " + castGuard.getName()
+ " DeclaredType of superApiClassifier '" + superApiDeclaredType.getClass().getName()
+ "' ");
}
}
}
}
示例6: create
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
*
*/
public static Condition create(String[] nameList) throws ConditionException {
if (nameList == null) {
throw new ConditionException("name list may not be null");
}
if (nameList.length == 0) {
throw new ConditionException("name list may not be empty");
}
if (nameList.length == 1) {
return new Condition(new String[]{normalize(checkName(nameList[0]))});
}
LinkedHashSet<String> nameSet = new LinkedHashSet<>();
for (int i=0;i<nameList.length;i++) {
nameSet.add(normalize(checkName(nameList[i])));
}
return new Condition(nameSet.toArray(SystemToolkit.EMPTY_STRING_ARRAY));
}
示例7: ForwardedUserFilter
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public ForwardedUserFilter(String headerName,
Function<HttpServletRequest, User> userFactory,
Collection<String> requestAttributeNames) {
Assert.hasText(headerName, "headerName cannot be null or empty.");
Assert.notNull(userFactory, "userFactory function cannot be null.");
this.headerName = headerName;
this.userFactory = userFactory;
//always ensure that the fully qualified interface name is accessible:
LinkedHashSet<String> set = new LinkedHashSet<>();
set.add(User.class.getName());
if (!Collections.isEmpty(requestAttributeNames)) {
set.addAll(requestAttributeNames);
}
this.requestAttributeNames = set;
}
示例8: filterPolicySetsByPriority
import java.util.LinkedHashSet; //导入方法依赖的package包/类
LinkedHashSet<PolicySet> filterPolicySetsByPriority(final String subjectIdentifier, final String uri,
final List<PolicySet> allPolicySets, final LinkedHashSet<String> policySetsEvaluationOrder)
throws IllegalArgumentException {
if (policySetsEvaluationOrder.isEmpty()) {
if (allPolicySets.size() > 1) {
LOGGER.error(
"Found more than one policy set during policy evaluation and "
+ "no evaluation order is provided. subjectIdentifier='{}', resourceURI='{}'",
subjectIdentifier, uri);
throw new IllegalArgumentException("More than one policy set exists for this zone. "
+ "Please provide an ordered list of policy set names to consider for this evaluation and "
+ "resubmit the request.");
} else {
return new LinkedHashSet<>(allPolicySets);
}
}
Map<String, PolicySet> allPolicySetsMap = allPolicySets.stream()
.collect(Collectors.toMap(PolicySet::getName, Function.identity()));
LinkedHashSet<PolicySet> filteredPolicySets = new LinkedHashSet<>();
for (String policySetId : policySetsEvaluationOrder) {
PolicySet policySet = allPolicySetsMap.get(policySetId);
if (policySet == null) {
LOGGER.error("No existing policy set matches policy set in the evaluation order of the request. "
+ "Subject: {}, Resource: {}", subjectIdentifier, uri);
throw new IllegalArgumentException(
"No existing policy set matches policy set in the evaluaion order of the request. "
+ "Please review the policy evauation order and resubmit the request.");
} else {
filteredPolicySets.add(policySet);
}
}
return filteredPolicySets;
}
示例9: toSet
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Returns a [Set] containing all unique elements.
* <p>
* The returned set preserves the element iteration order of the original collection.
*/
public static <T> Set<T> toSet( @This Iterable<T> thiz )
{
if( thiz instanceof Collection )
{
return ((Collection<T>)thiz).toSet();
}
LinkedHashSet<T> set = new LinkedHashSet<>();
for( T elem : thiz )
{
set.add( elem );
}
return set;
}
示例10: getSelectionIds
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public LinkedHashSet<Long> getSelectionIds() {
LinkedHashSet<Long> result = new LinkedHashSet<Long>();
for (int i = 0; i < selection.size(); i++) {
result.add(selection.get(i).getId());
}
return result;
}
示例11: keySet
import java.util.LinkedHashSet; //导入方法依赖的package包/类
@Override
public Set<K> keySet() {
//todo implement
//should only return keys where this is active.
LinkedHashSet<K> set = new LinkedHashSet<K>(innerMap.size());
Iterator<Map.Entry<K,MapEntry<K,V>>> i = innerMap.entrySet().iterator();
while ( i.hasNext() ) {
Map.Entry<K,MapEntry<K,V>> e = i.next();
K key = e.getKey();
MapEntry<K,V> entry = innerMap.get(key);
if ( entry!=null && entry.isActive() ) set.add(key);
}
return Collections.unmodifiableSet(set);
}
示例12: store
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Stores the listed object under the specified hash key in map. Unlike a
* standard map, the listed object will not replace any object already at
* the appropriate Map location, but rather will be appended to a List
* stored in that location.
*/
private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) {
LinkedHashSet<L> list = map.get(hashed);
if (list == null) {
list = new LinkedHashSet<>(1);
map.put(hashed, list);
}
if (!list.contains(listed)) {
list.add(listed);
}
}
示例13: main
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public static void main(String[] args) {
LinkedHashSet<String> lhs = new LinkedHashSet<>();
lhs.add("C");
lhs.add("A");
lhs.add("D");
lhs.add("B");
lhs.add("A");
lhs.add("C");
System.out.println("Add some element. Content: " + lhs.toString());
}
示例14: handleHtmlMimeTypes
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private static LinkedHashSet<String> handleHtmlMimeTypes(String baseType,
String mimeType) {
LinkedHashSet<String> returnValues = new LinkedHashSet<>();
if (HTML_TEXT_BASE_TYPE.equals(baseType)) {
for (String documentType : htmlDocumntTypes) {
returnValues.add(mimeType + ";document=" + documentType);
}
} else {
returnValues.add(mimeType);
}
return returnValues;
}
示例15: handleHtmlMimeTypes
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private static LinkedHashSet<String> handleHtmlMimeTypes(String baseType,
String mimeType) {
LinkedHashSet<String> returnValues = new LinkedHashSet<>();
if (HTML_TEXT_BASE_TYPE.equals(baseType)) {
for (String documentType : htmlDocumentTypes) {
returnValues.add(mimeType + ";document=" + documentType);
}
} else {
returnValues.add(mimeType);
}
return returnValues;
}