本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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 + ".";
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例15: withMaximumSizes
import com.google.common.collect.Sets; //导入方法依赖的package包/类
CacheBuilderFactory withMaximumSizes(Set<Integer> maximumSizes) {
this.maximumSizes = Sets.newLinkedHashSet(maximumSizes);
return this;
}