Java Code Examples for com.google.common.collect.Interner#intern()
The following examples show how to use
com.google.common.collect.Interner#intern() .
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: ScriptMonitor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public ScriptMonitor ( final String id, final String factoryId, final Executor executor, final BundleContext context, final Interner<String> stringInterner, final EventProcessor eventProcessor, final ObjectPoolTracker<DataSource> dataSourcePoolTracker, final ObjectPoolTracker<MasterItem> masterItemPoolTracker, final ServiceTracker<ConfigurationAdministrator, ConfigurationAdministrator> caTracker ) { super ( id, factoryId, executor, context, stringInterner, eventProcessor ); this.executor = executor; this.prefix = stringInterner.intern ( factoryId + ". " + id ); //$NON-NLS-1$ this.classLoader = getClass ().getClassLoader (); this.monitorStateInjector = new MonitorStateInjector ( stringInterner ); this.monitorStateInjector.setPrefix ( this.prefix ); this.handler = new InjectMasterHandler ( id, masterItemPoolTracker, 0, caTracker, this.prefix, factoryId ); this.listener = new MultiDataSourceListener ( dataSourcePoolTracker ) { @Override protected void handleChange ( final Map<String, DataSourceHandler> sources ) { ScriptMonitor.this.handleChange ( sources ); } }; }
Example 2
Source File: NinjaScope.java From bazel with Apache License 2.0 | 6 votes |
private String computeExpandedString( long offset, String key, Map<String, String> cache, ImmutableSet<String> variablesToNotExpand, Interner<String> interner) { String cachedValue = cache.get(key); if (cachedValue != null) { return cachedValue; } if (variablesToNotExpand.contains(key)) { return null; } String expandedValue = findExpandedVariable(offset, key); // It's very important an interner is used here, as there is considerable duplication of // string literals in expanded rule-variable-parts over the course of a large build. return expandedValue == null ? null : interner.intern(expandedValue); }
Example 3
Source File: AbstractConfigurableMasterHandlerImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected String getPrefixed ( final String id, final Interner<String> stringInterner ) { if ( id == null ) { return this.prefix; } else { return stringInterner.intern ( this.dotPrefix + id ); } }
Example 4
Source File: SourceMapConsumerV1.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Split the file into a filename/directory pair. * * @param interner The interner to use for interning the strings. * @param input The input to split. * @return The pair of directory, filename. */ private FileName splitFileName( Interner<String> interner, String input) { int hashIndex = input.lastIndexOf('/'); String dir = interner.intern(input.substring(0, hashIndex + 1)); String fileName = interner.intern(input.substring(hashIndex + 1)); return new FileName(dir, fileName); }
Example 5
Source File: RuleClass.java From bazel with Apache License 2.0 | 5 votes |
/** * Converts the build-language-typed {@code buildLangValue} to a native value via {@link * BuildType#selectableConvert}. Canonicalizes the value's order if it is a {@link List} type and * {@code attr.isOrderIndependent()} returns {@code true}. * * <p>Throws {@link ConversionException} if the conversion fails, or if {@code buildLangValue} is * a selector expression but {@code attr.isConfigurable()} is {@code false}. */ private static Object convertFromBuildLangType( Rule rule, Attribute attr, Object buildLangValue, ImmutableMap<RepositoryName, RepositoryName> repositoryMapping, Interner<ImmutableList<?>> listInterner) throws ConversionException { LabelConversionContext context = new LabelConversionContext(rule.getLabel(), repositoryMapping); Object converted = BuildType.selectableConvert( attr.getType(), buildLangValue, new AttributeConversionContext(attr.getName(), rule.getRuleClass()), context); if ((converted instanceof SelectorList<?>) && !attr.isConfigurable()) { throw new ConversionException( String.format("attribute \"%s\" is not configurable", attr.getName())); } if (converted instanceof List<?>) { if (attr.isOrderIndependent()) { @SuppressWarnings("unchecked") List<? extends Comparable<?>> list = (List<? extends Comparable<?>>) converted; converted = Ordering.natural().sortedCopy(list); } // It's common for multiple rule instances in the same package to have the same value for some // attributes. As a concrete example, consider a package having several 'java_test' instances, // each with the same exact 'tags' attribute value. converted = listInterner.intern(ImmutableList.copyOf((List<?>) converted)); } return converted; }
Example 6
Source File: MerkleTreeNodeCache.java From buck with Apache License 2.0 | 5 votes |
public MerkleTreeNode build(Interner<MerkleTreeNode> nodeInterner) { ImmutableSortedMap.Builder<Path, MerkleTreeNode> children = ImmutableSortedMap.naturalOrder(); childrenBuilder.forEach( (key, value) -> children.put( key, value.transform(left -> left, builder -> builder.build(nodeInterner)))); return nodeInterner.intern( new MerkleTreeNode( path, children.build(), ImmutableSortedMap.copyOf(filesBuilder), ImmutableSortedMap.copyOf(symlinksBuilder), ImmutableSortedMap.copyOf(emptyDirectoryBuilder))); }