com.google.common.collect.ImmutableBiMap.Builder Java Examples
The following examples show how to use
com.google.common.collect.ImmutableBiMap.Builder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrefixConverters.java From yangtools with Eclipse Public License 1.0 | 6 votes |
/** * Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG * {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules * and their namespaces. This information is cached and used for improved lookups. * * @param ctx A SchemaContext * @param module Module in which the XPath is defined * @return A new Converter */ public static @NonNull Converter<String, QNameModule> create(final SchemaContext ctx, final Module module) { // Always check for null ctx requireNonNull(ctx, "Schema context may not be null"); // Use immutable map builder for detection of duplicates (which should never occur) final Builder<String, QNameModule> b = ImmutableBiMap.builder(); b.put(module.getPrefix(), module.getQNameModule()); for (ModuleImport i : module.getImports()) { final Optional<? extends Module> mod = ctx.findModule(i.getModuleName(), i.getRevision()); checkArgument(mod.isPresent(), "Unsatisfied import of %s by module %s", i, module); b.put(i.getPrefix(), mod.get().getQNameModule()); } return Maps.asConverter(b.build()); }
Example #2
Source File: TieredSFCIndexStrategy.java From geowave with Apache License 2.0 | 6 votes |
@Override public void fromBinary(final byte[] bytes) { final ByteBuffer buf = ByteBuffer.wrap(bytes); final int numSfcs = VarintUtils.readUnsignedInt(buf); final int numDimensions = VarintUtils.readUnsignedInt(buf); final int mappingSize = VarintUtils.readUnsignedInt(buf); maxEstimatedDuplicateIdsPerDimension = VarintUtils.readUnsignedLong(buf); orderedSfcs = new SpaceFillingCurve[numSfcs]; baseDefinitions = new NumericDimensionDefinition[numDimensions]; for (int i = 0; i < numSfcs; i++) { final byte[] sfc = ByteArrayUtils.safeRead(buf, VarintUtils.readUnsignedInt(buf)); orderedSfcs[i] = (SpaceFillingCurve) PersistenceUtils.fromBinary(sfc); } for (int i = 0; i < numDimensions; i++) { final byte[] dim = ByteArrayUtils.safeRead(buf, VarintUtils.readUnsignedInt(buf)); baseDefinitions[i] = (NumericDimensionDefinition) PersistenceUtils.fromBinary(dim); } final Builder<Integer, Byte> bimapBuilder = ImmutableBiMap.builder(); for (int i = 0; i < mappingSize; i++) { bimapBuilder.put(Byte.valueOf(buf.get()).intValue(), buf.get()); } orderedSfcIndexToTierId = bimapBuilder.build(); initDuplicateIdLookup(); }
Example #3
Source File: BiMapYangNamespaceContext.java From yangtools with Eclipse Public License 1.0 | 5 votes |
public static BiMapYangNamespaceContext readFrom(final DataInput in) throws IOException { final int size = in.readInt(); final Builder<String, QNameModule> builder = ImmutableBiMap.builder(); for (int i = 0; i < size; ++i) { final String prefix = in.readUTF(); final QNameModule namespace = QNameModule.readFrom(in); builder.put(prefix, namespace); } return new BiMapYangNamespaceContext(builder.build()); }
Example #4
Source File: ModuleNameNamespaceContext.java From yangtools with Eclipse Public License 1.0 | 5 votes |
/** * Convert this object to an equivalent {@link BiMapYangNamespaceContext}. * * @return A BiMapYangNamespaceContext. */ public BiMapYangNamespaceContext toBiMap() { final Builder<String, QNameModule> builder = ImmutableBiMap.builder(); for (String name : schemaContext.getModules().stream().map(Module::getName).collect(Collectors.toSet())) { builder.put(name, findNamespaceForPrefix(name).get()); } return new BiMapYangNamespaceContext(builder.build()); }
Example #5
Source File: Universe.java From Intake with GNU Lesser General Public License v3.0 | 5 votes |
public Map<String, Body> getPrefixedWith(String prefix) { ImmutableMap.Builder<String, Body> matching = new Builder<String, Body>(); for (Map.Entry<String, Body> entry : bodies.entrySet()) { if (entry.getKey().startsWith(prefix)) { matching.put(entry); } } return matching.build(); }
Example #6
Source File: NamespaceContextBuilder.java From arctic-sea with Apache License 2.0 | 4 votes |
private Builder<String, String> getNamespaces() { return this.bimap; }