本文整理匯總了Java中com.google.common.collect.Interner類的典型用法代碼示例。如果您正苦於以下問題:Java Interner類的具體用法?Java Interner怎麽用?Java Interner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Interner類屬於com.google.common.collect包,在下文中一共展示了Interner類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeInterner
import com.google.common.collect.Interner; //導入依賴的package包/類
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 ();
}
}
示例2: ScriptMonitor
import com.google.common.collect.Interner; //導入依賴的package包/類
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 );
}
};
}
示例3: loadCitiesDMARegions
import com.google.common.collect.Interner; //導入依賴的package包/類
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);
}
示例4: makeNoOpInterner
import com.google.common.collect.Interner; //導入依賴的package包/類
public static Interner<String> makeNoOpInterner ()
{
return new Interner<String> () {
@Override
public String intern ( final String string )
{
return string;
}
};
}
示例5: AbstractMasterItemMonitor
import com.google.common.collect.Interner; //導入依賴的package包/類
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 );
}
示例6: JdbcStorageDao
import com.google.common.collect.Interner; //導入依賴的package包/類
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 );
}
示例7: AbstractMonitorService
import com.google.common.collect.Interner; //導入依賴的package包/類
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 );
}
示例8: getPrefixed
import com.google.common.collect.Interner; //導入依賴的package包/類
protected String getPrefixed ( final String id, final Interner<String> stringInterner )
{
if ( id == null )
{
return this.prefix;
}
else
{
return stringInterner.intern ( this.dotPrefix + id );
}
}
示例9: ScriptMonitorFactory
import com.google.common.collect.Interner; //導入依賴的package包/類
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;
}
示例10: ConfigurationAdminImpl
import com.google.common.collect.Interner; //導入依賴的package包/類
public ConfigurationAdminImpl ( final BundleContext context, final Interner<String> stringInterner ) throws Exception
{
super ( context );
this.stringInterner = stringInterner;
this.context = context;
initRoot ();
}
示例11: BitMonitorFactory
import com.google.common.collect.Interner; //導入依賴的package包/類
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;
}
示例12: LevelMonitorFactory
import com.google.common.collect.Interner; //導入依賴的package包/類
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;
}
示例13: ListMonitorFactory
import com.google.common.collect.Interner; //導入依賴的package包/類
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;
}
示例14: test
import com.google.common.collect.Interner; //導入依賴的package包/類
@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);
}
示例15: testInvalidBuild
import com.google.common.collect.Interner; //導入依賴的package包/類
@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());
}