本文整理汇总了Java中com.google.common.collect.ImmutableMultimap.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于com.google.common.collect.ImmutableMultimap包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBuilder_withMutableEntry
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public void testBuilder_withMutableEntry() {
ImmutableMultimap.Builder<String, Integer> builder =
new Builder<String, Integer>();
final StringHolder holder = new StringHolder();
holder.string = "one";
Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
@Override public String getKey() {
return holder.string;
}
@Override public Integer getValue() {
return 1;
}
};
builder.put(entry);
holder.string = "two";
assertEquals(Arrays.asList(1), builder.build().get("one"));
}
示例2: pathPropertiesOfAsMultimap
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public static ImmutableMultimap<String, Object> pathPropertiesOfAsMultimap(Blob blob, Function<String, Collection<String>> pathPropertyMapping, Path path, PropertyCollectionResolver propertyResolver) {
ImmutableList<String> pathProperties = path.propertyNamesWithoutPage();
ImmutableMap<String, ImmutableSet<?>> blopPathPropertyMap = pathProperties.stream()
.map(p -> Pair.<String, ImmutableSet<?>>of(p, propertyOf(blob, pathPropertyMapping, propertyResolver, p)))
.filter(pair -> !pair.b().isEmpty())
.collect(ImmutableMap.toImmutableMap(Pair::a, Pair::b));
if (blopPathPropertyMap.keySet().size()<pathProperties.size()) {
return ImmutableMultimap.of();
}
Builder<String, Object> multiMapBuilder = ImmutableMultimap.builder();
blopPathPropertyMap.forEach((key, values) -> {
multiMapBuilder.putAll(key, values);
});
return multiMapBuilder.build();
}
示例3: registerNotificationListener
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
@Override
public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener, final Collection<SchemaPath> types) {
final ListenerRegistration<T> reg = new AbstractListenerRegistration<T>(listener) {
@Override
protected void removeRegistration() {
final ListenerRegistration<T> me = this;
synchronized (DOMNotificationRouter.this) {
replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, input -> input != me)));
}
}
};
if (!types.isEmpty()) {
final Builder<SchemaPath, ListenerRegistration<? extends DOMNotificationListener>> b = ImmutableMultimap.builder();
b.putAll(listeners);
for (final SchemaPath t : types) {
b.put(t, reg);
}
replaceListeners(b.build());
}
return reg;
}
示例4: methodCallsForSymbol
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
/**
* Finds all method invocations on the given symbol, and constructs a map of the called method's
* name, to the {@link MethodInvocationTree} in which it was called.
*/
private ImmutableMultimap<String, MethodInvocationTree> methodCallsForSymbol(
Symbol sym, ClassTree classTree) {
Builder<String, MethodInvocationTree> methodMap = ImmutableMultimap.builder();
// Populate map builder with names of method called : the tree in which it is called.
classTree.accept(
new TreeScanner<Void, Void>() {
@Override
public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) {
if (sym.equals(getSymbol(getReceiver(callTree)))) {
MethodSymbol methodSymbol = getSymbol(callTree);
if (methodSymbol != null) {
methodMap.put(methodSymbol.getSimpleName().toString(), callTree);
}
}
return super.visitMethodInvocation(callTree, unused);
}
},
null);
return methodMap.build();
}
示例5: testBuilder_withMutableEntry
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public void testBuilder_withMutableEntry() {
ImmutableMultimap.Builder<String, Integer> builder = new Builder<>();
final StringHolder holder = new StringHolder();
holder.string = "one";
Entry<String, Integer> entry =
new AbstractMapEntry<String, Integer>() {
@Override
public String getKey() {
return holder.string;
}
@Override
public Integer getValue() {
return 1;
}
};
builder.put(entry);
holder.string = "two";
assertEquals(Arrays.asList(1), builder.build().get("one"));
}
示例6: buildInternal
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
private void buildInternal(ImmutableList.Builder<Step> steps) {
Preconditions.checkState(newInputsHash != null, "Must call checkIsCached first!");
createDxStepForDxPseudoRule(
target,
androidPlatformTarget,
steps,
buildContext,
filesystem,
srcs,
outputPath,
dxOptions,
xzCompressionLevel,
dxMaxHeapSize,
dexTool);
steps.add(
new WriteFileStep(filesystem, newInputsHash, outputHashPath, /* executable */ false));
}
示例7: orderByKey
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public static ImmutableMultimap<ImmutableMap<String, Object>, Blob> orderByKey(ImmutableMultimap<ImmutableMap<String, Object>, Blob> src,
ImmutableList<String> pathOrdering) {
ImmutableMultimap.Builder<ImmutableMap<String, Object>, Blob> builder=ImmutableMultimap.builder();
src.asMap().entrySet()
.stream()
.sorted(pathOrderingOf(pathOrdering))
.forEach(e -> {
builder.putAll(e.getKey(), e.getValue());
});
return builder.build();
}
示例8: BratRelation
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public BratRelation(BratRelationType type, BratEntity arg1, BratEntity arg2) {
super(type, ImmutableMultimap.<String, BratEntity>of());
if (!checkArgVal(arg1) || !checkArgVal(arg2)) {
throw new IllegalArgumentException(String.format(
"Relation %s arguments: %s, %s", type, arg1, arg2));
}
Builder<String, BratEntity> b = ImmutableMultimap.builder();
b.put(type.getArg1Name(), arg1);
b.put(type.getArg2Name(), arg2);
setRoleAnnotations(b.build());
}
示例9: MaterialEventHandlerRegistry
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public MaterialEventHandlerRegistry(
@NonNull final Optional<Collection<MaterialEventHandler>> handlers,
@NonNull final EventLogUserService eventLogUserService)
{
this.eventLogUserService = eventLogUserService;
final Builder<Class, MaterialEventHandler> builder = createEventHandlerMapping(handlers);
eventType2Handler = builder.build();
}
示例10: createEventHandlerMapping
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
private Builder<Class, MaterialEventHandler> createEventHandlerMapping(
@NonNull final Optional<Collection<MaterialEventHandler>> handlers)
{
final Builder<Class, MaterialEventHandler> builder = ImmutableMultimap.builder();
for (final MaterialEventHandler handler : handlers.orElse(ImmutableList.of()))
{
final Collection<Class<? extends MaterialEventHandler>> handeledEventType = //
handler.getHandeledEventType();
handeledEventType.forEach(type -> builder.put(type, handler));
}
return builder;
}
示例11: getActionContexts
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
@Override
public Multimap<Class<? extends ActionContext>, String> getActionContexts() {
Builder<Class<? extends ActionContext>, String> contexts = ImmutableMultimap.builder();
contexts.put(SpawnActionContext.class, "standalone");
contexts.put(SpawnActionContext.class, "worker");
return contexts.build();
}
示例12: createPartitionSpec
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
private Map<String, String> createPartitionSpec() {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (HCatFieldSchema partitionColumn : partitionColumns) {
String name = partitionColumn.getName();
Object value = get(name);
checkState(value != null, "Value for partition column %s must not be null.", name);
builder.put(name, value.toString());
}
return builder.build();
}
示例13: SmartDexingStep
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
/**
* @param primaryOutputPath Path for the primary dex artifact.
* @param primaryInputsToDex Set of paths to include as inputs for the primary dex artifact.
* @param secondaryOutputDir Directory path for the secondary dex artifacts, if there are any.
* Note that this directory will be pruned such that only those secondary outputs generated by
* this command will remain in the directory!
* @param secondaryInputsToDex List of paths to input jar files, to use as dx input, keyed by the
* corresponding output dex file. Note that for each output file (key), a separate dx
* invocation will be started with the corresponding jar files (value) as the input.
* @param successDir Directory where success artifacts are written.
* @param executorService The thread pool to execute the dx command on.
*/
public SmartDexingStep(
BuildTarget target,
AndroidPlatformTarget androidPlatformTarget,
BuildContext buildContext,
ProjectFilesystem filesystem,
final Path primaryOutputPath,
final Supplier<Set<Path>> primaryInputsToDex,
Optional<Path> secondaryOutputDir,
final Optional<Supplier<Multimap<Path, Path>>> secondaryInputsToDex,
DexInputHashesProvider dexInputHashesProvider,
Path successDir,
EnumSet<Option> dxOptions,
ListeningExecutorService executorService,
Optional<Integer> xzCompressionLevel,
Optional<String> dxMaxHeapSize,
String dexTool) {
this.target = target;
this.androidPlatformTarget = androidPlatformTarget;
this.buildContext = buildContext;
this.filesystem = filesystem;
this.outputToInputsSupplier =
MoreSuppliers.memoize(
() -> {
final Builder<Path, Path> map = ImmutableMultimap.builder();
map.putAll(primaryOutputPath, primaryInputsToDex.get());
if (secondaryInputsToDex.isPresent()) {
map.putAll(secondaryInputsToDex.get().get());
}
return map.build();
});
this.secondaryOutputDir = secondaryOutputDir;
this.dexInputHashesProvider = dexInputHashesProvider;
this.successDir = successDir;
this.dxOptions = dxOptions;
this.executorService = executorService;
this.xzCompressionLevel = xzCompressionLevel;
this.dxMaxHeapSize = dxMaxHeapSize;
this.dexTool = dexTool;
}
示例14: generateDxCommands
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
/**
* Once the {@code .class} files have been split into separate zip files, each must be converted
* to a {@code .dex} file.
*/
private ImmutableList<ImmutableList<Step>> generateDxCommands(
ProjectFilesystem filesystem, Multimap<Path, Path> outputToInputs) {
ImmutableList.Builder<DxPseudoRule> pseudoRules = ImmutableList.builder();
ImmutableMap<Path, Sha1HashCode> dexInputHashes = dexInputHashesProvider.getDexInputHashes();
for (Path outputFile : outputToInputs.keySet()) {
pseudoRules.add(
new DxPseudoRule(
target,
androidPlatformTarget,
buildContext,
filesystem,
dexInputHashes,
ImmutableSet.copyOf(outputToInputs.get(outputFile)),
outputFile,
successDir.resolve(outputFile.getFileName()),
dxOptions,
xzCompressionLevel,
dxMaxHeapSize,
dexTool));
}
ImmutableList.Builder<ImmutableList<Step>> stepGroups = new ImmutableList.Builder<>();
for (DxPseudoRule pseudoRule : pseudoRules.build()) {
if (!pseudoRule.checkIsCached()) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
pseudoRule.buildInternal(steps);
stepGroups.add(steps.build());
}
}
return stepGroups.build();
}
示例15: testBuilder_withImmutableEntry
import com.google.common.collect.ImmutableMultimap.Builder; //导入依赖的package包/类
public void testBuilder_withImmutableEntry() {
ImmutableMultimap<String, Integer> multimap = new Builder<String, Integer>()
.put(Maps.immutableEntry("one", 1))
.build();
assertEquals(Arrays.asList(1), multimap.get("one"));
}