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


Java Sets.newLinkedHashSet方法代码示例

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


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

示例1: runCommonTestsWith

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private static void runCommonTestsWith(
    AuthorityClassifier p,
    String... shouldMatch) {

  ImmutableList<String> matches = ImmutableList.copyOf(shouldMatch);
  Set<String> notMatchSet = Sets.newLinkedHashSet(MAY_MATCH);
  notMatchSet.removeAll(matches);
  ImmutableList<String> notMatches = ImmutableList.copyOf(notMatchSet);

  ImmutableMap<Classification, ImmutableList<String>> inputs =
      ImmutableMap.of(
          Classification.INVALID, MUST_BE_INVALID,
          Classification.MATCH, matches,
          Classification.NOT_A_MATCH, notMatches);

  runTests(p, inputs);
}
 
开发者ID:OWASP,项目名称:url-classifier,代码行数:18,代码来源:AuthorityClassifierBuilderTest.java

示例2: testDeterministicNesting

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void testDeterministicNesting() throws JsonProcessingException
{
    @SuppressWarnings("unused")
    Object obj = new Object() {
        public String get1() { return "1"; }
        public String getC() { return "C"; }
        public String getA() { return "A"; }
    };

    Set<Integer> ints = Sets.newLinkedHashSet(Lists.newArrayList(1, 4, 2, 3, 5, 7, 8, 9, 6, 0, 50, 100, 99));

    Map<String, Object> data = Maps.newLinkedHashMap();
    data.put("obj", obj);
    data.put("c", "C");
    data.put("ints", ints);

    String actual = mapper.writer().writeValueAsString(data);
    String expected = "{" +
                        "\"c\":\"C\"," +
                        "\"ints\":[0,1,2,3,4,5,6,7,8,9,50,99,100]," +
                        "\"obj\":{\"1\":\"1\",\"a\":\"A\",\"c\":\"C\"}" +
                      "}";
    assertEquals(expected, actual);
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:26,代码来源:DeterministicObjectMapperTest.java

示例3: selectConfigurations

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public Set<ConfigurationMetadata> selectConfigurations(ComponentResolveMetadata fromComponent, ConfigurationMetadata fromConfiguration, ComponentResolveMetadata targetComponent, AttributesSchema attributesSchema) {
    Set<ConfigurationMetadata> result = Sets.newLinkedHashSet();
    boolean requiresCompile = fromConfiguration.getName().equals("compile");
    if (!requiresCompile) {
        // From every configuration other than compile, include both the runtime and compile dependencies
        ConfigurationMetadata runtime = findTargetConfiguration(fromComponent, fromConfiguration, targetComponent, "runtime");
        result.add(runtime);
        requiresCompile = !runtime.getHierarchy().contains("compile");
    }
    if (requiresCompile) {
        // From compile configuration, or when the target's runtime configuration does not extend from compile, include the compile dependencies
        result.add(findTargetConfiguration(fromComponent, fromConfiguration, targetComponent, "compile"));
    }
    ConfigurationMetadata master = targetComponent.getConfiguration("master");
    if (master != null && (!master.getDependencies().isEmpty() || !master.getArtifacts().isEmpty())) {
        result.add(master);
    }
    return result;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:MavenDependencyMetadata.java

示例4: getReportedComponents

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<ComponentSpec> getReportedComponents(Set<ComponentSpec> allComponents) {
    if (components == null || components.isEmpty()) {
        return allComponents;
    }
    Set<ComponentSpec> reportedComponents = Sets.newLinkedHashSet();
    List<String> notFound = Lists.newArrayList(components);
    for (ComponentSpec candidate : allComponents) {
        String candidateName = candidate.getName();
        if (components.contains(candidateName)) {
            reportedComponents.add(candidate);
            notFound.remove(candidateName);
        }
    }
    if (!notFound.isEmpty()) {
        onComponentsNotFound(notFound);
    }
    return reportedComponents;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:DependentComponentsReport.java

示例5: getMessage

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public String getMessage() {
	StringBuilder typeListStr = new StringBuilder();
	IdentifiableElement first = (IdentifiableElement) EcoreUtil.resolve(getEObjectOrProxy(), context);
	String typeIdent = first instanceof Type ? "type" : "variable";
	TModule module = (TModule) first.eContainer();
	typeListStr.append(module.getQualifiedName());
	Set<IdentifiableElement> uniqueTypes = Sets.newLinkedHashSet(elements);
	uniqueTypes.remove(first);
	Iterator<IdentifiableElement> iter = uniqueTypes.iterator();
	while (iter.hasNext()) {
		IdentifiableElement type = iter.next();
		if (iter.hasNext()) {
			typeListStr.append(", ");
		} else {
			typeListStr.append(" and ");
		}
		typeListStr.append(((TModule) type.eContainer()).getQualifiedName());
	}
	if (this.issueCode == IssueCodes.IMP_AMBIGUOUS_WILDCARD) {
		return IssueCodes.getMessageForIMP_AMBIGUOUS_WILDCARD(typeIdent, getName(), typeListStr.toString());
	} else if (this.issueCode == IssueCodes.IMP_AMBIGUOUS) {
		return IssueCodes.getMessageForIMP_AMBIGUOUS(typeIdent, getName(), typeListStr.toString());
	} else if (this.issueCode == IssueCodes.IMP_DUPLICATE_NAMESPACE) {
		return IssueCodes.getMessageForIMP_DUPLICATE_NAMESPACE(getName(), "stub");
	}
	return "Unknown ambiguous import issue: " + this.issueCode + " for " + context + ".";
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:AmbiguousImportDescription.java

示例6: newProxy

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * Returns a new proxy for {@code interfaceType}. Proxies of the same interface are equal to each
 * other if the {@link DummyProxy} instance that created the proxies are equal.
 */
final <T> T newProxy(TypeToken<T> interfaceType) {
  Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
  interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
  // Make the proxy serializable to work with SerializableTester
  interfaceClasses.add(Serializable.class);
  Object dummy = Proxy.newProxyInstance(
      interfaceClasses.iterator().next().getClassLoader(),
      interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
      new DummyHandler(interfaceType));
  @SuppressWarnings("unchecked") // interfaceType is T
  T result = (T) dummy;
  return result;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:DummyProxy.java

示例7: determineManagedPropertyType

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private static ModelType<?> determineManagedPropertyType(StructBindingExtractionContext<?> extractionContext, String propertyName, Multimap<PropertyAccessorType, StructMethodBinding> accessorBindings) {
    Collection<StructMethodBinding> isGetter = accessorBindings.get(IS_GETTER);
    for (StructMethodBinding isGetterBinding : isGetter) {
        if (!((ManagedPropertyMethodBinding) isGetterBinding).getDeclaredPropertyType().equals(ModelType.of(Boolean.TYPE))) {
            WeaklyTypeReferencingMethod<?, ?> isGetterMethod = isGetterBinding.getViewMethod();
            extractionContext.add(isGetterMethod, String.format("it should either return 'boolean', or its name should be '%s()'",
                "get" + isGetterMethod.getName().substring(2)));
        }
    }
    Set<ModelType<?>> potentialPropertyTypes = Sets.newLinkedHashSet();
    for (StructMethodBinding binding : accessorBindings.values()) {
        if (binding.getAccessorType() == SETTER) {
            continue;
        }
        ManagedPropertyMethodBinding propertyBinding = (ManagedPropertyMethodBinding) binding;
        potentialPropertyTypes.add(propertyBinding.getDeclaredPropertyType());
    }
    Collection<ModelType<?>> convergingPropertyTypes = findConvergingTypes(potentialPropertyTypes);
    if (convergingPropertyTypes.size() != 1) {
        extractionContext.add(propertyName, String.format("it must have a consistent type, but it's defined as %s",
            Joiner.on(", ").join(ModelTypes.getDisplayNames(convergingPropertyTypes))));
        return convergingPropertyTypes.iterator().next();
    }
    ModelType<?> propertyType = Iterables.getOnlyElement(convergingPropertyTypes);

    for (StructMethodBinding setterBinding : accessorBindings.get(SETTER)) {
        ManagedPropertyMethodBinding propertySetterBinding = (ManagedPropertyMethodBinding) setterBinding;
        ModelType<?> declaredSetterType = propertySetterBinding.getDeclaredPropertyType();
        if (!declaredSetterType.equals(propertyType)) {
            extractionContext.add(setterBinding.getViewMethod(), String.format("it should take parameter with type '%s'",
                propertyType.getDisplayName()));
        }
    }
    return propertyType;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:36,代码来源:DefaultStructBindingsStore.java

示例8: collectRootUrlAsFiles

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<File> collectRootUrlAsFiles(List<Node> nodes) {
    Set<File> files = Sets.newLinkedHashSet();
    for (Node node : nodes) {
        for (Node root : getChildren(node, "root")) {
            String url = (String) root.attribute("url");
            files.add(new File(url));
        }
    }
    return files;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:Project.java

示例9: getWhitelistedDiff

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public static Map<String, PendingChange> getWhitelistedDiff(Whitelisted pending, Whitelisted current) {
    Map<String, PendingChange> diff = new TreeMap<>();
    Set<String> allPendingPaths = pending.getPaths() != null ? Sets.newLinkedHashSet(pending.getPaths()) : new LinkedHashSet<String>();
    Set<String> allCurrentPaths = current.getPaths() != null ? Sets.newLinkedHashSet(current.getPaths()) : new LinkedHashSet<String>();

    Set<String> added = getAddedPaths(allPendingPaths, allCurrentPaths);
    Set<String> deleted = getDeletedPaths(allPendingPaths, allCurrentPaths);

    putAddedPathsToDiff(diff, added);
    putDeletedPathsToDiff(diff, deleted);

    return diff;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:14,代码来源:PendingWhitelistedDiffHelper.java

示例10: testDeterministicSetInts

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void testDeterministicSetInts() throws JsonProcessingException
{
    Set<Integer> ints = Sets.newLinkedHashSet(Lists.newArrayList(1, 3, 2));
    String actual = mapper.writer().writeValueAsString(ints);
    String expected = "[1,2,3]";
    assertEquals(expected, actual);
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:9,代码来源:DeterministicObjectMapperTest.java

示例11: getFiles

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * Recursive but excludes unsuccessfully resolved artifacts.
 */
public Set<File> getFiles(Spec<? super Dependency> dependencySpec) {
    Set<File> files = Sets.newLinkedHashSet();
    FilesAndArtifactCollectingVisitor visitor = new FilesAndArtifactCollectingVisitor(files);
    visitArtifacts(dependencySpec, configuration.getAttributes(), selectedArtifacts, selectedFileDependencies, visitor);
    files.addAll(getFiles(filterUnresolved(visitor.artifacts)));
    return files;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:DefaultLenientConfiguration.java

示例12: getResolvedComponents

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public Set<ComponentArtifactsResult> getResolvedComponents() {
    Set<ComponentArtifactsResult> resolvedComponentResults = Sets.newLinkedHashSet();
    for (ComponentResult componentResult : componentResults) {
        if (componentResult instanceof ComponentArtifactsResult) {
            resolvedComponentResults.add((ComponentArtifactsResult) componentResult);
        }
    }
    return resolvedComponentResults;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:DefaultArtifactResolutionResult.java

示例13: getArtifacts

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public Set<ArtifactResult> getArtifacts(Class<? extends Artifact> type) {
    Set<ArtifactResult> matching = Sets.newLinkedHashSet();
    for (ArtifactResult artifactResult : artifactResults) {
        if (type.isAssignableFrom(artifactResult.getType())) {
            matching.add(artifactResult);
        }
    }
    return matching;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:DefaultComponentArtifactsResult.java

示例14: getNotYetRenamedElements

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<T> getNotYetRenamedElements(Collection<T> elementsToRename) {
    Set<T> notYetRenamed = Sets.newLinkedHashSet();
    for (T element : elementsToRename) {
        if (!hasBeenRenamed(element)) {
            notYetRenamed.add(element);
        }
    }
    return notYetRenamed;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:HierarchicalElementDeduplicator.java

示例15: withMaximumSizes

import com.google.common.collect.Sets; //导入方法依赖的package包/类
CacheBuilderFactory withMaximumSizes(Set<Integer> maximumSizes) {
  this.maximumSizes = Sets.newLinkedHashSet(maximumSizes);
  return this;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:5,代码来源:CacheBuilderFactory.java


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