public ImmutableBiMap<ModContainer, Object> buildModObjectList() { ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder(); for (ModContainer mc : activeModList) { if (!mc.isImmutable() && mc.getMod()!=null) { builder.put(mc, mc.getMod()); List<String> packages = mc.getOwnedPackages(); for (String pkg : packages) { packageOwners.put(pkg, mc); } } if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING) { FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId()); if (state != LoaderState.CONSTRUCTING) { this.errorOccurred(mc, new RuntimeException()); } } } return builder.build(); }
default void use() { ImmutableExtraCollection.of( ImmutableList.<String>of(), ImmutableMultimap.<Integer, String>of(), ImmutableMultimap.<Integer, String>of(), ImmutableMultimap.<Integer, String>of(), ImmutableBiMap.<Integer, String>of()); ImmutableExtraCollection.of(); ImmutableExtraCollection collection = ImmutableExtraCollection.builder() .addBag("2", "2") .putIndex(1, "2", "3", "4") .putAllIndex(1, Arrays.asList("2", "3", "4")) .putIndex(2, "5") .putIndexList(1, "") .putIndexSet(2, "2") .putAllIndexSet(2, Arrays.asList("3", "4")) .putBiMap(1, "a") .putBiMap(2, "b") .putAllBiMap(Collections.singletonMap(3, "c")) .build(); collection.bag().count("2"); collection.index().get(1); collection.indexList().get(1); collection.indexSet().get(2); }
public static ClassRenamingMapper from(ClassNameMapper originalMap, ClassNameMapper targetMap) { ImmutableBiMap.Builder<String, String> translationBuilder = ImmutableBiMap.builder(); ImmutableSet.Builder<String> newClasses = ImmutableSet.builder(); BiMap<String, String> sourceObfuscatedToOriginal = originalMap.getObfuscatedToOriginalMapping(); BiMap<String, String> sourceOriginalToObfuscated = sourceObfuscatedToOriginal.inverse(); BiMap<String, String> targetObfuscatedToOriginal = targetMap.getObfuscatedToOriginalMapping(); BiMap<String, String> targetOriginalToObfuscated = targetObfuscatedToOriginal.inverse(); for (String originalName : sourceOriginalToObfuscated.keySet()) { String sourceObfuscatedName = sourceOriginalToObfuscated.get(originalName); String targetObfuscatedName = targetOriginalToObfuscated.get(originalName); if (targetObfuscatedName == null) { newClasses.add(originalName); continue; } translationBuilder.put(sourceObfuscatedName, targetObfuscatedName); } ImmutableBiMap<String, String> translation = translationBuilder.build(); ImmutableSet<String> unusedNames = ImmutableSet .copyOf(Sets.difference(targetObfuscatedToOriginal.keySet(), translation.values())); return new ClassRenamingMapper(translation, newClasses.build(), unusedNames); }
private static ImmutableSet<CharOffsetSpan> matchJustificationsForDoc( final Iterable<DocEventFrameReference> eventFramesMatchedInDoc, final DocumentSystemOutput2015 docSystemOutput) { final Optional<ImmutableBiMap<String, ResponseSet>> responseSetMap = docSystemOutput.linking().responseSetIds(); checkState(responseSetMap.isPresent()); final ImmutableSet.Builder<CharOffsetSpan> offsetsB = ImmutableSet.builder(); for (final DocEventFrameReference docEventFrameReference : eventFramesMatchedInDoc) { final ResponseSet rs = checkNotNull(responseSetMap.get().get(docEventFrameReference.eventFrameID())); final ImmutableSet<Response> responses = rs.asSet(); final ImmutableSet<CharOffsetSpan> spans = FluentIterable.from(responses) .transformAndConcat(ResponseFunctions.predicateJustifications()).toSet(); offsetsB.addAll(spans); } return offsetsB.build(); }
GqlInputConverter build() { HashBiMap<String, Descriptor> mapping = HashBiMap.create(); HashBiMap<String, EnumDescriptor> enumMapping = HashBiMap.create(getEnumMap(enumDescriptors)); LinkedList<Descriptor> loop = new LinkedList<>(descriptors); Set<FileDescriptor> fileDescriptorSet = ProtoRegistry.extractDependencies(fileDescriptors); for (FileDescriptor fileDescriptor : fileDescriptorSet) { loop.addAll(fileDescriptor.getMessageTypes()); enumMapping.putAll(getEnumMap(fileDescriptor.getEnumTypes())); } while (!loop.isEmpty()) { Descriptor descriptor = loop.pop(); if (!mapping.containsKey(descriptor.getFullName())) { mapping.put(getReferenceName(descriptor), descriptor); loop.addAll(descriptor.getNestedTypes()); enumMapping.putAll(getEnumMap(descriptor.getEnumTypes())); } } return new GqlInputConverter( ImmutableBiMap.copyOf(mapping), ImmutableBiMap.copyOf(enumMapping)); }
/** * HashBiMap 修改数据 * putAll * remove * replace */ @Test public void testUpdateBiMapDate() { BiMap<String, String> biMap = HashBiMap.create(); biMap.put("k1", "v1"); biMap.put("k2", "v2"); // putAll , 存入另一个Map的数据,此时如果value有重复的依然会抛异常 biMap.putAll(ImmutableBiMap.of("k3", "v3", "k4", "v4", "k5", "v5", "k6", "v6")); System.out.println("biMap putAll after: " + biMap); System.out.println("\n-------------------------------------------\n"); // remove , 移除指定key的元素,如果key不存在,则返回null String v2 = biMap.remove("k2"); String valueNotExists = biMap.remove("keyNotExists"); System.out.println("remove k2 then biMap= " + biMap + ", and remove the value= " + v2); System.out.println("valueNotExists=" + valueNotExists); System.out.println("\n-------------------------------------------\n"); // 清空map里的数据 biMap.clear(); System.out.println("clean biMap=" + biMap); }
public ImmutableBiMap<ModContainer, Object> buildModObjectList() { ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.builder(); for (ModContainer mc : activeModList) { if (!mc.isImmutable() && mc.getMod()!=null) { builder.put(mc, mc.getMod()); List<String> packages = mc.getOwnedPackages(); for (String pkg : packages) { packageOwners.put(pkg, mc); } } if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING) { FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId()); if (state != LoaderState.CONSTRUCTING) { this.errorOccurred(mc, new RuntimeException()); } } } return builder.build(); }
Long resolveShardForPath(final YangInstanceIdentifier path) { final String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path); Long cookie = shards.get(shardName); if (cookie == null) { synchronized (this) { cookie = shards.get(shardName); if (cookie == null) { cookie = nextShard++; Builder<String, Long> builder = ImmutableBiMap.builder(); builder.putAll(shards); builder.put(shardName, cookie); shards = builder.build(); } } } return cookie; }
/** * Creates a new {@link ModuleRegistry} * * @param modules The modules in the registry to be created. */ public ModuleRegistry(@NonNull Map<Class, Module> modules) { Validate.notNull(modules); this.modules = new ImmutableBiMap.Builder<Class, Module>().putAll(modules).build(); DependencyGraph<Module> graph = new DependencyGraph<Module>(); this.modules.values().forEach(module -> { graph.add(module); ModuleEntry moduleEntry = module.getClass().getAnnotation(ModuleEntry.class); for (Class dep : moduleEntry.depends()) { graph.addDependency(module, modules.get(dep)); } for (Class before : moduleEntry.loadBefore()) { graph.addDependency(modules.get(before), module); } }); loadOrder = graph.evaluateDependencies(); }
LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) { this.traitValues = traitValues; this.baseState = baseState; ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder(); for (BlockTrait trait : traitValues.keySet()) { builder.put(((LanternBlockTrait) trait).getKey(), trait); } this.keyToBlockTrait = builder.build(); final StringBuilder idBuilder = new StringBuilder(); idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1)); if (!traitValues.isEmpty()) { idBuilder.append('['); final Joiner joiner = Joiner.on(','); final List<String> propertyValues = new ArrayList<>(); for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) { propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH)); } idBuilder.append(joiner.join(propertyValues)); idBuilder.append(']'); } this.name = idBuilder.toString(); this.id = baseState.getBlockType().getPluginId() + ':' + this.name; }
Support(final Expr expr, final String body, final Set<URI> properties, final Map<String, String> namespaces) { super(null, XPathFunction.CONTEXT, VARIABLES, XPathNavigator.INSTANCE); final StringBuilder builder = new StringBuilder(); for (final String prefix : Ordering.natural().sortedCopy(namespaces.keySet())) { final String namespace = namespaces.get(prefix); if (!namespace.equals(Data.getNamespaceMap().get(prefix))) { builder.append(builder.length() == 0 ? "" : ", ").append(prefix).append(": ") .append("<").append(namespace).append(">"); } } final String head = builder.toString(); this.string = head.isEmpty() ? body : "with " + head + " : " + body; this.head = head.isEmpty() ? "" : this.string.substring(5, 5 + head.length()); this.body = head.isEmpty() ? body : this.string.substring(8 + head.length()); this.expr = expr; this.properties = properties; this.namespaces = ImmutableBiMap.copyOf(namespaces); }
HierarchicalTypeStore(MemRepository repository, HierarchicalType hierarchicalType) throws RepositoryException { this.hierarchicalType = (IConstructableType) hierarchicalType; this.repository = repository; ImmutableMap.Builder<AttributeInfo, IAttributeStore> b = new ImmutableBiMap.Builder<>(); typeNameList = Lists.newArrayList((String) null); ImmutableList<AttributeInfo> l = hierarchicalType.immediateAttrs; for (AttributeInfo i : l) { b.put(i, AttributeStores.createStore(i)); } attrStores = b.build(); ImmutableList.Builder<HierarchicalTypeStore> b1 = new ImmutableList.Builder<>(); Set<String> allSuperTypeNames = hierarchicalType.getAllSuperTypeNames(); for (String s : allSuperTypeNames) { b1.add(repository.getStore(s)); } superTypeStores = b1.build(); nextPos = 0; idPosMap = new HashMap<>(); freePositions = new ArrayList<>(); lock = new ReentrantReadWriteLock(); }
/** Creates users workspace object based on the status and machines RAM. */ private static WorkspaceImpl createWorkspace(WorkspaceStatus status, Integer... machineRams) { final Map<String, MachineImpl> machines = new HashMap<>(machineRams.length - 1); final Map<String, MachineConfigImpl> machineConfigs = new HashMap<>(machineRams.length - 1); byte i = 1; for (Integer machineRam : machineRams) { final String machineName = "machine_" + i++; machines.put(machineName, createMachine(machineRam)); machineConfigs.put(machineName, createMachineConfig(machineRam)); } return WorkspaceImpl.builder() .setConfig( WorkspaceConfigImpl.builder() .setEnvironments( ImmutableBiMap.of(ACTIVE_ENV_NAME, new EnvironmentImpl(null, machineConfigs))) .build()) .setRuntime(new RuntimeImpl(ACTIVE_ENV_NAME, machines, null)) .setStatus(status) .build(); }
@Override protected TapFlow toMd(NeutronTapFlow flow) { final TapFlowBuilder flowBuilder = new TapFlowBuilder(); toMdBaseAttributes(flow, flowBuilder); if (flow.getTapFlowServiceID() != null) { flowBuilder.setTapServiceId(toUuid(flow.getTapFlowServiceID())); } if (flow.getTapFlowSourcePort() != null) { flowBuilder.setSourcePort(toUuid(flow.getTapFlowSourcePort())); } if (flow.getTapFlowDirection() != null) { final ImmutableBiMap<String, Class<? extends DirectionBase>> mapper = DIRECTION_MAP.inverse(); flowBuilder.setDirection(mapper.get(flow.getTapFlowDirection())); } return flowBuilder.build(); }
@Override protected Trunk toMd(NeutronTrunk trunk) { final TrunkBuilder trunkBuilder = new TrunkBuilder(); toMdAdminAttributes(trunk, trunkBuilder); if (trunk.getPortId() != null) { trunkBuilder.setPortId(toUuid(trunk.getPortId())); } if (trunk.getSubPorts() != null) { final List<SubPorts> subPortsList = new ArrayList<>(); final SubPortsBuilder subPortsBuilder = new SubPortsBuilder(); final ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper = NETWORK_TYPE_MAP.inverse(); for (NeutronTrunkSubPort subPort: trunk.getSubPorts()) { subPortsBuilder.setPortId(toUuid(subPort.getPortId())); subPortsBuilder.setSegmentationType(mapper.get(subPort.getSegmentationType())); subPortsBuilder.setSegmentationId(Long.valueOf(subPort.getSegmentationId())); subPortsList.add(subPortsBuilder.build()); } trunkBuilder.setSubPorts(subPortsList); } return trunkBuilder.build(); }
/** * Transform all the original data in the specified mapping, using this mapping. * * This is useful for {@link #createRenamingMappings(UnaryOperator, Function, Function)}, * since renaming mappings have no 'original' data of their own, and so can't be directly output to a file. * The returned mapping data is guaranteed to have the same originals as the data of the old mapping data. * * @return the transformed data */ default Mappings transform(Mappings original) { ImmutableBiMap.Builder<JavaType, JavaType> types = ImmutableBiMap.builder(); ImmutableBiMap.Builder<MethodData, MethodData> methods = ImmutableBiMap.builder(); ImmutableBiMap.Builder<FieldData, FieldData> fields = ImmutableBiMap.builder(); original.classes().forEach(originalType -> { JavaType newType = this.getNewType(originalType); types.put(originalType, newType); }); original.methods().forEach(originalMethodData -> { MethodData newMethodData = this.getNewMethod(originalMethodData); methods.put(originalMethodData, newMethodData); }); original.fields().forEach(originalFieldData -> { FieldData newFieldData = this.getNewField(originalFieldData); fields.put(originalFieldData, newFieldData); }); return ImmutableMappings.create(types.build(), methods.build(), fields.build()); }
@SuppressWarnings("rawtypes") private Leaves2DataConverter() { converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new TreeDataValue(TreeTypes.ACACIA), (byte) 0) .put(new TreeDataValue(TreeTypes.DARK_OAK), (byte) 1) .build(), (byte) 2 ); applicableTypes.add(TreeData.class); converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new DecayableDataValue(false), (byte) 0) .put(new DecayableDataValue(true), (byte) 1) .build(), (byte) 1 ); applicableTypes.add(DecayableData.class); }
ScannerSupplierImpl( ImmutableBiMap<String, BugCheckerInfo> checks, ImmutableMap<String, SeverityLevel> severities, ImmutableSet<String> disabled, ErrorProneFlags flags) { checkArgument( Sets.difference(severities.keySet(), checks.keySet()).isEmpty(), "enabledChecks must be a subset of allChecks"); checkArgument( Sets.difference(disabled, checks.keySet()).isEmpty(), "disabled must be a subset of allChecks"); this.checks = checks; this.severities = severities; this.disabled = disabled; this.flags = flags; }
/** * Composes this {@link ScannerSupplier} with the {@code other} {@link ScannerSupplier}. The set * of checks that are turned on is the intersection of the checks on in {@code this} and {@code * other}. */ @CheckReturnValue public ScannerSupplier plus(ScannerSupplier other) { ImmutableBiMap<String, BugCheckerInfo> combinedAllChecks = ImmutableBiMap.<String, BugCheckerInfo>builder() .putAll(this.getAllChecks()) .putAll(other.getAllChecks()) .build(); ImmutableMap<String, SeverityLevel> combinedSeverities = ImmutableMap.<String, SeverityLevel>builder() .putAll(severities()) .putAll(other.severities()) .build(); ImmutableSet<String> disabled = ImmutableSet.copyOf(Sets.union(disabled(), other.disabled())); ErrorProneFlags combinedFlags = this.getFlags().plus(other.getFlags()); return new ScannerSupplierImpl(combinedAllChecks, combinedSeverities, disabled, combinedFlags); }
private static String upperToHttpHeaderName( String constantName, ImmutableBiMap<String, String> specialCases, ImmutableSet<String> uppercaseAcronyms) { if (specialCases.containsKey(constantName)) { return specialCases.get(constantName); } List<String> parts = Lists.newArrayList(); for (String part : SPLITTER.split(constantName)) { if (!uppercaseAcronyms.contains(part)) { part = part.charAt(0) + Ascii.toLowerCase(part.substring(1)); } parts.add(part); } return JOINER.join(parts); }
public Environment(ImmutableBiMap<String, V> nodeIds, ImmutableBiMap<String, E> edgeIds, int threads, MultiPeriodCyclePackingInputs<V, E, T> multiPeriodInputs, TimeWriter<T> timeWriter, ObjectiveBuilder objectiveBuilder, int replications, PredicateFactory<V, E> predicateFactory, HistoricData<V, E> historicData) { this.nodeIds = nodeIds; this.edgeIds = edgeIds; this.multiPeriodInputs = multiPeriodInputs; this.threads = threads; threadPool = FixedThreadPool.makePool(threads); maxSolveTimeSeconds = Optional.of(60.0); solverOptions = SolverOption.defaultOptions; this.timeWriter = timeWriter; this.objectiveBuilder = objectiveBuilder; this.replications = replications; this.predicateFactory = predicateFactory; this.historicData = historicData; }
private ImmutableBiMap<UnosDataHeader, Integer> getHeaderColumns( CSVRecord headerRow) { ImmutableBiMap.Builder<UnosDataHeader, Integer> ans = ImmutableBiMap .builder(); for (int i = 0; i < headerRow.size(); i++) { String header = headerRow.get(i); if (dataHeaderNames.inverse().containsKey(header)) { ans.put(dataHeaderNames.inverse().get(header), i); } } ImmutableBiMap<UnosDataHeader, Integer> ansBuilt = ans.build(); if (ansBuilt.size() != dataHeaderNames.size()) { throw new RuntimeException("Expected " + dataHeaderNames.size() + " headers but found: " + ansBuilt.size() + ". Values: " + ansBuilt + ", Missing: " + Sets.difference(EnumSet.allOf(UnosDataHeader.class), ansBuilt.keySet())); } return ansBuilt; }
@SuppressWarnings("rawtypes") private Log2DataConverter() { converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new LogDataConverter.TreeDataValue(TreeTypes.ACACIA), (byte) 0) .put(new LogDataConverter.TreeDataValue(TreeTypes.DARK_OAK), (byte) 1) .build(), (byte) 2 ); applicableTypes.add(TreeData.class); converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new LogDataConverter.AxisDataValue(Axis.Y), (byte) 0) .put(new LogDataConverter.AxisDataValue(Axis.X), (byte) 1) .put(new LogDataConverter.AxisDataValue(Axis.Z), (byte) 2) .put(new LogDataConverter.AxisDataValue(null), (byte) 3) .build(), (byte) 2 ); applicableTypes.add(AxisData.class); }
@SuppressWarnings("rawtypes") private LeavesDataConverter() { converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new LogDataConverter.TreeDataValue(TreeTypes.OAK), (byte) 0) .put(new LogDataConverter.TreeDataValue(TreeTypes.SPRUCE), (byte) 1) .put(new LogDataConverter.TreeDataValue(TreeTypes.BIRCH), (byte) 2) .put(new LogDataConverter.TreeDataValue(TreeTypes.JUNGLE), (byte) 3) .build(), (byte) 2 ); applicableTypes.add(TreeData.class); converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new DecayableDataValue(false), (byte) 0) .put(new DecayableDataValue(true), (byte) 1) .build(), (byte) 1 ); applicableTypes.add(DecayableData.class); }
CompiledTemplateRegistry(TemplateRegistry registry) { Map<String, Optional<SanitizedContentKind>> deltemplateNameToContentKind = new HashMap<>(); ImmutableBiMap.Builder<String, CompiledTemplateMetadata> templateToMetadata = ImmutableBiMap.builder(); ImmutableBiMap.Builder<String, CompiledTemplateMetadata> classToMetadata = ImmutableBiMap.builder(); ImmutableSet.Builder<String> delegateTemplateNames = ImmutableSet.builder(); for (TemplateNode template : registry.getAllTemplates()) { CompiledTemplateMetadata metadata = CompiledTemplateMetadata.create(template.getTemplateName(), template); templateToMetadata.put(template.getTemplateName(), metadata); classToMetadata.put(metadata.typeInfo().className(), metadata); if (template instanceof TemplateDelegateNode) { delegateTemplateNames.add(template.getTemplateName()); // all delegates are guaranteed to have the same content kind by the // checkdelegatesvisitor deltemplateNameToContentKind.put( ((TemplateDelegateNode) template).getDelTemplateName(), Optional.fromNullable(template.getContentKind())); } } this.templateNameToMetadata = templateToMetadata.build(); this.classNameToMetadata = classToMetadata.build(); this.deltemplateNameToContentKind = ImmutableMap.copyOf(deltemplateNameToContentKind); this.delegateTemplateNames = delegateTemplateNames.build(); }
public static RevisionAwareXPath parseXPath(final StmtContext<?, ?, ?> ctx, final String path) { final XPath xPath = XPATH_FACTORY.get().newXPath(); xPath.setNamespaceContext(StmtNamespaceContext.create(ctx, ImmutableBiMap.of(RFC6020_YANG_NAMESPACE.toString(), YANG_XPATH_FUNCTIONS_PREFIX))); final String trimmed = trimSingleLastSlashFromXPath(path); try { // XPath extension functions have to be prefixed // yang-specific XPath functions are in fact extended functions, therefore we have to add // "yang" prefix to them so that they can be properly validated with the XPath.compile() method // the "yang" prefix is bound to RFC6020 YANG namespace final String prefixedXPath = addPrefixToYangXPathFunctions(trimmed, ctx); // TODO: we could capture the result and expose its 'evaluate' method xPath.compile(prefixedXPath); } catch (final XPathExpressionException e) { LOG.warn("Argument \"{}\" is not valid XPath string at \"{}\"", path, ctx.getStatementSourceReference(), e); } return new RevisionAwareXPathImpl(path, PATH_ABS.matcher(path).matches()); }
/** * Creates a command that filters a specified set of directories. * @param inResDirToOutResDirMap set of {@code res} directories to filter * @param filterDrawables whether to filter drawables (images) * @param filterStrings whether to filter non-english strings * @param whitelistedStringDirs set of directories containing string resource files that must not * be filtered out. * @param filteredDirectoryCopier refer {@link FilteredDirectoryCopier} * @param targetDensities densities we're interested in keeping (e.g. {@code mdpi}, {@code hdpi} * etc.) Only applicable if filterDrawables is true * @param drawableFinder refer {@link DrawableFinder}. Only applicable if filterDrawables is true. * @param imageScaler if not null, use the {@link ImageScaler} to downscale higher-density * drawables for which we weren't able to find an image file of the proper density (as opposed * to allowing Android to do it at runtime). Only applicable if filterDrawables. is true. */ @VisibleForTesting FilterResourcesStep( ImmutableBiMap<Path, Path> inResDirToOutResDirMap, boolean filterDrawables, boolean filterStrings, ImmutableSet<Path> whitelistedStringDirs, FilteredDirectoryCopier filteredDirectoryCopier, @Nullable Set<Filters.Density> targetDensities, @Nullable DrawableFinder drawableFinder, @Nullable ImageScaler imageScaler) { Preconditions.checkArgument(filterDrawables || filterStrings); Preconditions.checkArgument(!filterDrawables || (targetDensities != null && drawableFinder != null)); this.inResDirToOutResDirMap = Preconditions.checkNotNull(inResDirToOutResDirMap); this.filterDrawables = filterDrawables; this.filterStrings = filterStrings; this.whitelistedStringDirs = Preconditions.checkNotNull(whitelistedStringDirs); this.filteredDirectoryCopier = Preconditions.checkNotNull(filteredDirectoryCopier); this.targetDensities = targetDensities; this.drawableFinder = drawableFinder; this.imageScaler = imageScaler; this.nonEnglishStringFilesBuilder = ImmutableSet.builder(); }
public static List<ProtocolEntry> createMdsalProtocols(Bridge bridge) { Set<String> protocols = null; try { protocols = bridge.getProtocolsColumn().getData(); } catch (SchemaVersionMismatchException e) { schemaMismatchLog("protocols", "Bridge", e); } List<ProtocolEntry> protocolList = new ArrayList<>(); if (protocols != null && protocols.size() > 0) { ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper = SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse(); for (String protocol : protocols) { if (protocol != null && mapper.get(protocol) != null) { protocolList.add(new ProtocolEntryBuilder().setProtocol(mapper.get(protocol)).build()); } } } return protocolList; }
/** * Return the MD-SAL QoS type class corresponding to the QoS type {@link Qos}. * * @param type the QoS type to match {@link String} * @return class matching the input QoS type {@link QosTypeBase} */ public static Class<? extends QosTypeBase> createQosType(String type) { Preconditions.checkNotNull(type); if (type.isEmpty()) { LOG.info("QoS type not supplied"); return QosTypeBase.class; } else { ImmutableBiMap<String, Class<? extends QosTypeBase>> mapper = SouthboundConstants.QOS_TYPE_MAP.inverse(); if (mapper.get(type) == null) { LOG.info("QoS type not found in model: {}", type); return QosTypeBase.class; } else { return mapper.get(type); } } }
@SuppressWarnings("rawtypes") private LogDataConverter() { converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new TreeDataValue(TreeTypes.OAK), (byte) 0) .put(new TreeDataValue(TreeTypes.SPRUCE), (byte) 1) .put(new TreeDataValue(TreeTypes.BIRCH), (byte) 2) .put(new TreeDataValue(TreeTypes.JUNGLE), (byte) 3) .build(), (byte) 2 ); applicableTypes.add(TreeData.class); converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new AxisDataValue(Axis.Y), (byte) 0) .put(new AxisDataValue(Axis.X), (byte) 1) .put(new AxisDataValue(Axis.Z), (byte) 2) //TODO: add mapping for data value 3 (not yet in SpongeAPI) .build(), (byte) 2 ); applicableTypes.add(AxisData.class); }
@SuppressWarnings("rawtypes") private BigMushroomDataConverter() { converters.put( ImmutableBiMap.<AbstractDataValue, Byte>builder() .put(new BigMushroomDataValue(BigMushroomTypes.ALL_INSIDE), (byte) 0) .put(new BigMushroomDataValue(BigMushroomTypes.NORTH_WEST), (byte) 1) .put(new BigMushroomDataValue(BigMushroomTypes.NORTH), (byte) 2) .put(new BigMushroomDataValue(BigMushroomTypes.NORTH_EAST), (byte) 3) .put(new BigMushroomDataValue(BigMushroomTypes.WEST), (byte) 4) .put(new BigMushroomDataValue(BigMushroomTypes.CENTER), (byte) 5) .put(new BigMushroomDataValue(BigMushroomTypes.EAST), (byte) 6) .put(new BigMushroomDataValue(BigMushroomTypes.SOUTH_WEST), (byte) 7) .put(new BigMushroomDataValue(BigMushroomTypes.SOUTH), (byte) 8) .put(new BigMushroomDataValue(BigMushroomTypes.SOUTH_EAST), (byte) 9) .put(new BigMushroomDataValue(BigMushroomTypes.STEM), (byte) 10) .put(new BigMushroomDataValue(BigMushroomTypes.ALL_OUTSIDE), (byte) 14) .put(new BigMushroomDataValue(BigMushroomTypes.ALL_STEM), (byte) 15) .build(), (byte) 4); applicableTypes.add(BigMushroomData.class); }
@Test public void getProbability(){ Node node = new Node() .setScore("ham"); final BiMap<String, Node> entityRegistry = ImmutableBiMap.of("1", node); NodeScoreDistribution<Double> classification = new NodeScoreDistribution<Double>(new ValueMap<String, Double>(), node){ @Override public BiMap<String, Node> getEntityRegistry(){ return entityRegistry; } }; classification.put("ham", new DoubleValue(0.75d)); classification.put("spam", new DoubleValue(0.25d)); assertEquals(ImmutableSet.of("ham", "spam"), classification.getCategoryValues()); assertEquals((Double)0.75d, classification.getProbability("ham")); assertEquals((Double)0.25d, classification.getProbability("spam")); }
/** * Adds all custom arrow items to maps - should be done in post-init. */ public static void initializeArrows() { arrowMap.put(Items.arrow, EntityArrowCustom.class); arrowMap.put(ZSSItems.arrowBomb, EntityArrowBomb.class); arrowMap.put(ZSSItems.arrowBombFire, EntityArrowBomb.class); arrowMap.put(ZSSItems.arrowBombWater, EntityArrowBomb.class); arrowMap.put(ZSSItems.arrowFire, EntityArrowElemental.class); arrowMap.put(ZSSItems.arrowIce, EntityArrowElemental.class); arrowMap.put(ZSSItems.arrowLight, EntityArrowElemental.class); ImmutableBiMap.Builder<Item, BombType> builder = ImmutableBiMap.builder(); builder.put(ZSSItems.arrowBomb, BombType.BOMB_STANDARD); builder.put(ZSSItems.arrowBombFire, BombType.BOMB_FIRE); builder.put(ZSSItems.arrowBombWater, BombType.BOMB_WATER); bombArrowMap = builder.build(); elementalArrowMap.put(ZSSItems.arrowFire, ElementType.FIRE); elementalArrowMap.put(ZSSItems.arrowIce, ElementType.ICE); elementalArrowMap.put(ZSSItems.arrowLight, ElementType.LIGHT); }
public ImmutableBiMap<ModContainer, Object> buildModObjectList() { ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder(); for (ModContainer mc : activeModList) { if (!mc.isImmutable() && mc.getMod()!=null) { builder.put(mc, mc.getMod()); } if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING) { FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId()); if (state != LoaderState.CONSTRUCTING) { this.errorOccurred(mc, new RuntimeException()); } } } return builder.build(); }
@Test public void structFromConstructorSerializeDeserialize() throws Exception { ImmutableStructFromConstructor structFromConstructor = ImmutableStructFromConstructor.of( 2, Arrays.asList(1, 2), Optional.of("OPT"), ImmutableMultiset.of("list", "list"), ImmutableMultimap.of(1, "1"), ImmutableListMultimap.of(2, "2"), ImmutableBiMap.of(1, "2")) .withIndexSet(ImmutableListMultimap.of(3, "3")); check(deserialize(serialize(structFromConstructor))).is(structFromConstructor); }