Java 类com.google.common.collect.Interner 实例源码

项目:neoscada    文件:InternerHelper.java   
public static Interner<String> makeInterner ( final String specificPropertyName, final String defaultType )
{
    final String type = System.getProperty ( specificPropertyName, System.getProperty ( "org.eclipse.scada.defaultStringInterner", defaultType ) );
    if ( "weak".equals ( type ) )
    {
        return new NullSafeInterner ( Interners.<String> newWeakInterner () );
    }
    else if ( "strong".equals ( type ) )
    {
        return new NullSafeInterner ( Interners.<String> newStrongInterner () );
    }
    else if ( "java".equals ( type ) )
    {
        return new JavaStringInterner ();
    }
    else
    {
        return makeNoOpInterner ();
    }
}
项目:neoscada    文件:ScriptMonitor.java   
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 );
        }
    };
}
项目:openrtb-doubleclick    文件:DoubleClickMetadata.java   
private static ImmutableMap<CityDMARegionKey, CityDMARegionValue> loadCitiesDMARegions(
    Interner<String> interner, String resourceName) {
  Map<CityDMARegionKey, CityDMARegionValue> map = new LinkedHashMap<>();
  try (InputStream is = new ResourceTransport().open(resourceName)) {
    CSVParser.csvParser().parse(is, ".*,(\\d+),.*,.*,(\\d+)", fields -> {
      map.put(
          new CityDMARegionKey(
              Integer.parseInt(fields.get(1)),
              interner.intern(fields.get(3))),
          new CityDMARegionValue(
              Integer.parseInt(fields.get(4)),
              interner.intern(fields.get(0)),
              interner.intern(fields.get(2))));
      return true;
    });
  } catch (IOException e) {
    logger.warn(e.toString());
    return ImmutableMap.of();
  }
  return ImmutableMap.copyOf(map);
}
项目:neoscada    文件:InternerHelper.java   
public static Interner<String> makeNoOpInterner ()
{
    return new Interner<String> () {

        @Override
        public String intern ( final String string )
        {
            return string;
        }
    };
}
项目:neoscada    文件:AbstractMasterItemMonitor.java   
public AbstractMasterItemMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String factoryId, final String prefix, final String defaultMonitorType )
{
    super ( id, factoryId, executor, context, stringInterner, eventProcessor );
    this.factoryId = factoryId;
    this.executor = executor;
    this.poolTracker = poolTracker;

    this.defaultMonitorType = defaultMonitorType;

    this.monitorStateInjector = new MonitorStateInjector ( stringInterner );

    setPrefix ( prefix );
}
项目:neoscada    文件:JdbcStorageDao.java   
public JdbcStorageDao ( final DataSourceFactory dataSourceFactory, final Properties properties, final boolean usePool, final Long loginTimeout, final Interner<String> stringInterner ) throws SQLException
{
    super ( dataSourceFactory, properties, usePool, loginTimeout, stringInterner );

    this.executor = Executors.newSingleThreadScheduledExecutor ( new NamedThreadFactory ( "org.eclipse.scada.ae.server.storage.jdbc/CleanupThread" ) );
    this.executor.scheduleWithFixedDelay ( new Runnable () {

        @Override
        public void run ()
        {
            cleanupArchive ();
        }
    }, getCleanupPeriod (), getCleanupPeriod (), TimeUnit.SECONDS );
}
项目:neoscada    文件:AbstractMonitorService.java   
public AbstractMonitorService ( final String id, final Executor executor, final Interner<String> stringInterner )
{
    this.executor = executor;
    this.id = id;

    this.stringInterner = stringInterner == null ? InternerHelper.makeNoOpInterner () : stringInterner;

    this.currentState = new MonitorStatusInformation ( id, MonitorStatus.INIT, System.currentTimeMillis (), null, null, null, null, null, null, null );
}
项目:neoscada    文件:AbstractConfigurableMasterHandlerImpl.java   
protected String getPrefixed ( final String id, final Interner<String> stringInterner )
{
    if ( id == null )
    {
        return this.prefix;
    }
    else
    {
        return stringInterner.intern ( this.dotPrefix + id );
    }
}
项目:neoscada    文件:ScriptMonitorFactory.java   
public ScriptMonitorFactory ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final EventProcessor eventProcessor, final ObjectPoolTracker<DataSource> dataSourcePoolTracker, final ObjectPoolTracker<MasterItem> masterItemPoolTracker, final ServiceTracker<ConfigurationAdministrator, ConfigurationAdministrator> caTracker, final ObjectPoolImpl<MonitorService> monitorServicePool )
{
    super ( context );
    this.executor = executor;
    this.stringInterner = stringInterner;
    this.eventProcessor = eventProcessor;
    this.dataSourcePoolTracker = dataSourcePoolTracker;
    this.masterItemPoolTracker = masterItemPoolTracker;
    this.caTracker = caTracker;
    this.monitorServicePool = monitorServicePool;
}
项目:neoscada    文件:ConfigurationAdminImpl.java   
public ConfigurationAdminImpl ( final BundleContext context, final Interner<String> stringInterner ) throws Exception
{
    super ( context );
    this.stringInterner = stringInterner;
    this.context = context;
    initRoot ();
}
项目:neoscada    文件:BitMonitorFactory.java   
public BitMonitorFactory ( final BundleContext context, final ManageableObjectPool<MonitorService> servicePool, final EventProcessor eventProcessor, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker )
{
    super ( context, servicePool, eventProcessor );
    this.executor = executor;
    this.stringInterner = stringInterner;
    this.poolTracker = poolTracker;
}
项目:neoscada    文件:LevelMonitorFactory.java   
public LevelMonitorFactory ( final BundleContext context, final ManageableObjectPool<MonitorService> servicePool, final EventProcessor eventProcessor, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker )
{
    super ( context, servicePool, eventProcessor );
    this.executor = executor;
    this.stringInterner = stringInterner;
    this.poolTracker = poolTracker;
}
项目:neoscada    文件:ListMonitorFactory.java   
public ListMonitorFactory ( final BundleContext context, final ManageableObjectPool<MonitorService> servicePool, final EventProcessor eventProcessor, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker )
{
    super ( context, servicePool, eventProcessor );
    this.executor = executor;
    this.stringInterner = stringInterner;
    this.poolTracker = poolTracker;
}
项目:buffer-trigger    文件:MultiIntervalTriggerTest.java   
@Test
void test() {
    AtomicInteger assertSize = new AtomicInteger();
    BufferTrigger<Integer> bufferTrigger = SimpleBufferTrigger
            .<Integer, Set<Interner>> newGenericBuilder() //
            .triggerStrategy(new MultiIntervalTriggerStrategy() //
                    .on(10, SECONDS, 1) //
                    .on(5, SECONDS, 10) //
                    .on(1, SECONDS, 100) //
            ) //
            .consumer(set -> {
                System.out.println("size:" + set.size());
                assertEquals(set.size(), assertSize.get());
            }) //
            .build();

    enqueue(bufferTrigger, 100);
    assertSize.set(100);
    sleep(2);
    enqueue(bufferTrigger, 10);
    assertSize.set(10);
    sleep(6);
    enqueue(bufferTrigger, 1);
    assertSize.set(1);
    sleep(11);

    sleepUninterruptibly(10, SECONDS);
}
项目:buffer-trigger    文件:MultiIntervalTriggerTest.java   
@Test
void testInvalidBuild() {
    assertThrows(IllegalArgumentException.class,
            () -> SimpleBufferTrigger.<Integer, Set<Interner>> newGenericBuilder() //
                    .triggerStrategy(new MultiIntervalTriggerStrategy() //
                            .on(1, SECONDS, 1) //
                            .on(2, SECONDS, 2) //
                    ).consumer(set -> System.out.println("size:" + set.size())) //
                    .build());
}
项目:astor    文件:SourceMapConsumerV1.java   
/**
 * 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);
}
项目:openrtb-doubleclick    文件:DoubleClickMetadata.java   
/**
 * Creates the DoubleClickMetadata object.
 *
 * @param transport How to read the many files providing metadata information.
 *     Typically you will use one of the provided implementations,
 *     {@link URLConnectionTransport} or {@link ResourceTransport}
 */
@Inject
public DoubleClickMetadata(Transport transport) {
  Pattern ssvp = Pattern.compile("(\\d+)\\s+(.*)");
  Pattern csvp = Pattern.compile("(\\d+),(.*)");

  Interner<String> interner = Interners.<String>newStrongInterner();
  vendors = load(interner, transport, ssvp, ADX_DICT + "vendors.txt");
  gdnVendors = load(interner, transport, ssvp, ADX_DICT + "gdn-vendors.txt");
  HashMap<Integer, String> cats = new HashMap<>();
  cats.putAll(adSensitiveCategories = load(
      interner, transport, ssvp, ADX_DICT + "ad-sensitive-categories.txt"));
  cats.putAll(adProductCategories = load(
      interner, transport, ssvp, ADX_DICT + "ad-product-categories.txt"));
  cats.putAll(adRestrictedCategories = load(
      interner, transport, ssvp, ADX_DICT + "ad-restricted-categories.txt"));
  allAdCategories = ImmutableMap.copyOf(cats);
  agencies = load(interner, transport, ssvp, ADX_DICT + "agencies.txt");
  HashMap<Integer, String> attrs = new HashMap<>();
  attrs.putAll(pubExcCreativeAttributes =
      load(interner, transport, ssvp, ADX_DICT + "publisher-excludable-creative-attributes.txt"));
  attrs.putAll(buyDecCreativeAttributes =
      load(interner, transport, ssvp, ADX_DICT + "buyer-declarable-creative-attributes.txt"));
  allCreativeAttributes = ImmutableMap.copyOf(attrs);
  creativeStatusCodes = load(interner, transport, ssvp, ADX_DICT + "creative-status-codes.txt");
  sellerNetworks = load(interner, transport, ssvp, ADX_DICT + "seller-network-ids.txt");
  siteLists = load(interner, transport, ssvp, ADX_DICT + "site-lists.txt");
  contentLabels = load(interner, transport, ssvp, ADX_DICT + "content-labels.txt");
  publisherVerticals = load(interner, transport, ssvp, ADX_DICT + "publisher-verticals.txt");
  mobileCarriers = load(interner, transport, CSVParser.csvParser(), csvp,
      ADX_DICT + "mobile-carriers.csv");
  geoTargetsByCriteriaId = loadGeoTargets(interner, transport, ADX_DICT + "geo-table.csv");
  HashMap<GeoTarget.CanonicalKey, GeoTarget> byKey = new HashMap<>();
  for (GeoTarget target : geoTargetsByCriteriaId.values()) {
    byKey.put(target.key(), target);
  }
  geoTargetsByCanonicalKey = ImmutableMap.copyOf(byKey);
  dmaRegions = loadCitiesDMARegions(interner, ADX_DICT + "cities-dma-regions.csv");
  countryCodes = loadCountryCodes(interner, ADX_DICT + "countries.txt");
}
项目:miru    文件:MiruActivityInternExtern.java   
public MiruActivityInternExtern(MiruInterner<MiruIBA> ibaInterner,
    MiruInterner<MiruTenantId> tenantInterner,
    Interner<String> stringInterner,
    MiruTermComposer termComposer) {
    this.ibaInterner = ibaInterner;
    this.tenantInterner = tenantInterner;
    this.stringInterner = stringInterner;
    this.termComposer = termComposer;
}
项目:yangtools    文件:LeafInterner.java   
/**
 * Return a {@link LeafInterner} for a particular schema. Interner instances must not be reused for leaves of
 * different types, otherwise they may produce unexpected results.
 *
 * @param schema The leaf node's schema
 * @return An interner instance
 */
@Nonnull public static <T extends LeafNode<?>> Interner<T> forSchema(@Nullable final LeafSchemaNode schema) {
    if (schema != null) {
        final TypeDefinition<?> type = schema.getType();
        if (type instanceof BooleanTypeDefinition || type instanceof EnumTypeDefinition
                || type instanceof IdentityrefTypeDefinition) {
            return LeafInterner::intern;
        }
    }

    return Objects::requireNonNull;
}
项目:creeper    文件:PlayerManagement.java   
@Override
public void setMarkForDelete(boolean isMark) {
    Interner<String> interner = findInterner();
    synchronized (interner.intern(playerId)) {
        Optional<PlayerMetadata> playerMetadataOptional = gameManager.getPlayerManager().getPlayerMetadata(playerId);
        if (!playerMetadataOptional.isPresent()) {
            return;
        }
        PlayerMetadata playerMetadata = playerMetadataOptional.get();
        playerMetadata.setIsMarkedForDelete(isMark);
        gameManager.getPlayerManager().savePlayerMetadata(playerMetadata);
    }
}
项目:creeper    文件:PlayerManagement.java   
private Interner<String> findInterner() {
    Player player = gameManager.getPlayerManager().getPlayer(playerId);
    Interner<String> interner;
    if (player == null) {
        interner = Interners.newWeakInterner();
    } else {
        interner = player.getInterner();
    }
    return interner;
}
项目:closure-compiler-copy    文件:SourceMapConsumerV1.java   
/**
 * 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);
}
项目:neoscada    文件:InternerHelper.java   
private NullSafeInterner ( final Interner<String> interner )
{
    this.interner = interner;
}
项目:neoscada    文件:JdbcStorageDao.java   
public JdbcStorageDao ( final DataSourceFactory dataSourceFactory, final Properties properties, final boolean usePool, final Long loginTimeout, final Interner<String> stringInterner ) throws SQLException
{
    super ( dataSourceFactory, properties, usePool, loginTimeout, stringInterner );
}
项目:neoscada    文件:AbstractDemotingMasterItemMonitor.java   
public AbstractDemotingMasterItemMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String factoryId, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, factoryId, prefix, defaultMonitorType );
}
项目:neoscada    文件:MonitorStateInjector.java   
public MonitorStateInjector ( final Interner<String> stringInterner )
{
    this.stringInterner = stringInterner == null ? InternerHelper.makeNoOpInterner () : stringInterner;
}
项目:neoscada    文件:AbstractBooleanMonitor.java   
public AbstractBooleanMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String factoryId, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, factoryId, prefix, defaultMonitorType );
}
项目:neoscada    文件:AbstractNumericMonitor.java   
public AbstractNumericMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String factoryId, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, factoryId, prefix, defaultMonitorType );
}
项目:neoscada    文件:AbstractVariantMonitor.java   
public AbstractVariantMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String factoryId, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, factoryId, prefix, defaultMonitorType );
}
项目:neoscada    文件:AbstractJdbcStorageDao.java   
public AbstractJdbcStorageDao ( final DataSourceFactory dataSourceFactory, final Properties properties, final boolean usePool, final Long loginTimeout, final Interner<String> stringInterner ) throws SQLException
{
    super ( dataSourceFactory, properties, usePool, loginTimeout );
    this.stringInterner = stringInterner == null ? InternerHelper.makeNoOpInterner () : stringInterner;
}
项目:neoscada    文件:AbstractStateMonitor.java   
public AbstractStateMonitor ( final String id, final Executor executor, final Interner<String> stringInterner, final EventProcessor eventProcessor )
{
    super ( id, executor, stringInterner );
    this.eventProcessor = eventProcessor;
}
项目:neoscada    文件:Activator.java   
public static Interner<String> getStringInterner ()
{
    return instance.stringInterner;
}
项目:neoscada    文件:DefaultBinaryContext.java   
public DefaultBinaryContext ( final Charset charset, final Interner<String> stringInterner )
{
    this.encoder = charset.newEncoder ();
    this.decoder = charset.newDecoder ();
    this.stringInterner = stringInterner == null ? InternerHelper.makeNoOpInterner () : stringInterner;
}
项目:neoscada    文件:BitMonitor.java   
public BitMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, BitMonitorFactory.FACTORY_ID, prefix, defaultMonitorType );
}
项目:neoscada    文件:LevelMonitor.java   
public LevelMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, LevelMonitorFactory.FACTORY_ID, prefix, defaultMonitorType );
    this.firstPrefix = prefix;
}
项目:neoscada    文件:ListMonitor.java   
public ListMonitor ( final BundleContext context, final Executor executor, final Interner<String> stringInterner, final ObjectPoolTracker<MasterItem> poolTracker, final EventProcessor eventProcessor, final String id, final String prefix, final String defaultMonitorType )
{
    super ( context, executor, stringInterner, poolTracker, eventProcessor, id, ListMonitorFactory.FACTORY_ID, prefix, defaultMonitorType );
}
项目:bazel    文件:Canonicalizer.java   
/**
 * Creates an instance of Canonicalizer tracking path fragments.
 */
public static Interner<PathFragment> fragments() {
  return FRAGMENT_INTERNER;
}
项目:bazel    文件:BlazeInterners.java   
public static <T> Interner<T> newWeakInterner() {
  return setConcurrencyLevel(Interners.newBuilder().weak()).build();
}
项目:bazel    文件:BlazeInterners.java   
public static <T> Interner<T> newStrongInterner() {
  return setConcurrencyLevel(Interners.newBuilder().strong()).build();
}
项目:neoscada    文件:AbstractPersistentStateMonitor.java   
public AbstractPersistentStateMonitor ( final String id, final String factoryId, final Executor executor, final BundleContext context, final Interner<String> stringInterner, final EventProcessor eventProcessor )
{
    super ( id, executor, stringInterner, eventProcessor );

    this.context = context;

    this.tracker = new SingleServiceTracker<DataStore> ( context, DataStore.class, this.listener );

    this.nodeId = factoryId + "/" + id;

    this.tracker.open ();
}