本文整理匯總了Java中com.google.common.collect.MutableClassToInstanceMap類的典型用法代碼示例。如果您正苦於以下問題:Java MutableClassToInstanceMap類的具體用法?Java MutableClassToInstanceMap怎麽用?Java MutableClassToInstanceMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MutableClassToInstanceMap類屬於com.google.common.collect包,在下文中一共展示了MutableClassToInstanceMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
@Override
public ComponentMap get() {
ClassToInstanceMap<Object> components = MutableClassToInstanceMap.create();
components.putInstance(HolidaySource.class, _holidaySource);
components.putInstance(ConfigSource.class, _configSource);
components.putInstance(HistoricalTimeSeriesSource.class, _htsSource);
components.putInstance(ConventionBundleSource.class, _conventionBundleSource);
components.putInstance(HistoricalTimeSeriesResolver.class, _htsResolver);
components.putInstance(SecuritySource.class, _securitySource);
components.putInstance(ConventionSource.class, _conventionSource);
components.putInstance(RegionSource.class, _regionSource);
components.putInstance(PositionSource.class, _positionSource);
components.putInstance(MarketDataSnapshotSource.class, _snapshotSource);
components.putInstance(LegalEntitySource.class, _legalEntitySource);
components.putInstance(ExchangeSource.class, _exchangeSource);
ComponentMap componentMap = ComponentMap.of(components);
ServiceContext serviceContext = ServiceContext.of(componentMap.getComponents())
.with(VersionCorrectionProvider.class,
new FixedInstantVersionCorrectionProvider(Instant.now()));
ThreadLocalServiceContext.init(serviceContext);
return componentMap;
}
示例2: classToINstanceMap_example
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
@Test
public void classToINstanceMap_example () {
Person person = new Person("Jackson");
Jobs jobs = new Jobs("IT person");
Address address = new Address("505 Williams Street");
ClassToInstanceMap<Object> classToInstanceMap = MutableClassToInstanceMap.create();
classToInstanceMap.put(Person.class, person);
classToInstanceMap.put(Jobs.class, jobs);
classToInstanceMap.put(Address.class, address);
logger.info(classToInstanceMap);
assertEquals("IT person", classToInstanceMap.getInstance(Jobs.class).getJobName());
}
示例3: clone
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
/**
* Returns a copy of this configuration only including the given fragments (which the current
* configuration is assumed to have).
*/
public BuildConfiguration clone(
FragmentClassSet fragmentClasses, RuleClassProvider ruleClassProvider) {
ClassToInstanceMap<Fragment> fragmentsMap = MutableClassToInstanceMap.create();
for (Fragment fragment : fragments.values()) {
if (fragmentClasses.fragmentClasses().contains(fragment.getClass())) {
fragmentsMap.put(fragment.getClass(), fragment);
}
}
BuildOptions options = buildOptions.trim(
getOptionsClasses(fragmentsMap.keySet(), ruleClassProvider));
BuildConfiguration newConfig =
new BuildConfiguration(
directories,
fragmentsMap,
options,
mainRepositoryName.strippedName());
return newConfig;
}
示例4: init
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
void init(Set<? extends TypeElement> annotations, RoundEnvironment round, ProcessingEnvironment processing) {
this.components = MutableClassToInstanceMap.create();
this.processing = processing;
this.round = round;
this.annotations = ImmutableSet.copyOf(annotations);
this.initialized = true;
}
示例5: ProxyInvocationHandler
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
private ProxyInvocationHandler(
Map<String, BoundValue> options, Map<String, JsonNode> jsonOptions) {
this.options = options;
this.jsonOptions = jsonOptions;
this.knownInterfaces = new HashSet<>(PipelineOptionsFactory.getRegisteredOptions());
gettersToPropertyNames = Maps.newHashMap();
settersToPropertyNames = Maps.newHashMap();
interfaceToProxyCache = MutableClassToInstanceMap.create();
}
示例6: main
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public static void main(String[] args) {
ClassToInstanceMap<Number> numbers = MutableClassToInstanceMap.create();
numbers.putInstance(Integer.class, Integer.valueOf(0));
numbers.putInstance(Double.class, Double.valueOf(1));
numbers.putInstance(Float.class, Float.valueOf(3));
double myNum = numbers.getInstance(Double.class);
System.out.println(myNum);
}
示例7: doMock
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
private static MutableClassToInstanceMap<Object> doMock(List<Class<?>> classes, boolean isStrict) {
MutableClassToInstanceMap<Object> mocks = MutableClassToInstanceMap.create();
for (Class<?> clazz : classes) {
if (isStrict) {
mocks.put(clazz, strictMock(clazz));
} else {
mocks.put(clazz, mock(clazz));
}
}
return mocks;
}
示例8: ImmutableOptionRegistry
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
private <T1 extends Option<T1>> ImmutableOptionRegistry(Collection<T> options) {
/*
* we first have to create a mutable map, because the collection might contain options of the same class, where
* later ones will override previous ones. This would not be allowed by the builder of the immutable map.
*/
ClassToInstanceMap<T> mutableOptions = MutableClassToInstanceMap.create();
addToMap(mutableOptions, options);
this.options = ImmutableClassToInstanceMap.copyOf(mutableOptions);
}
示例9: getSetteAnnotations
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
/**
* Gets the map of SETTE annotations.
*
* @param element
* an annotated element
* @return a map of SETTE annotations
*/
public static ClassToInstanceMap<Annotation> getSetteAnnotations(
@NonNull AnnotatedElement element) {
ClassToInstanceMap<Annotation> setteAnnots = MutableClassToInstanceMap.create();
Arrays.stream(element.getAnnotations())
.filter(SetteAnnotationUtils::isSetteAnnotation)
.forEach(a -> setteAnnots.put(a.annotationType(), a));
return setteAnnots;
}
示例10: BehaviourBlock
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public BehaviourBlock(BMLBehaviorAttributeExtension... bmlBehaviorAttributeExtensions)
{
this.bmlBehaviorAttributeExtensions = MutableClassToInstanceMap.create();
for (BMLBehaviorAttributeExtension ext : bmlBehaviorAttributeExtensions)
{
this.bmlBehaviorAttributeExtensions.put(ext.getClass(), ext);
}
requiredBlocks = new ArrayList<RequiredBlock>();
constraintBlocks = new ArrayList<ConstraintBlock>();
behaviours = new ArrayList<Behaviour>();
}
示例11: fromResponse
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public <T extends ContentItem> ImmutableList<T> fromResponse(QueryResponse response, ContentItem.Schema<T> forcedSchema, FieldSet... additionalFields) {
ClassToInstanceMap<FieldDataSource<?>> context = MutableClassToInstanceMap.create();
context.put(QueryResponseDataSource.class, new QueryResponseDataSource(response));
Builder<T> builder = ImmutableList.builder();
for(SolrDocument doc : response.getResults()) {
context.put(SolrDocDataSource.class, new SolrDocDataSource(doc));
context.put(SchemaDataSource.class, new SchemaDataSource(forcedSchema));
builder.add(buildItem(forcedSchema, context, additionalFields));
}
return builder.build();
}
示例12: fromDocumentList
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public <T extends ContentItem> ImmutableList<T> fromDocumentList(SolrDocumentList list, ContentItem.Schema<T> forcedSchema, FieldSet... additionalFields) {
ClassToInstanceMap<FieldDataSource<?>> context = MutableClassToInstanceMap.create();
Builder<T> builder = ImmutableList.builder();
for(SolrDocument doc : list) {
context.put(SolrDocDataSource.class, new SolrDocDataSource(doc));
context.put(SchemaDataSource.class, new SchemaDataSource(forcedSchema));
builder.add(buildItem(forcedSchema, context, additionalFields));
}
return builder.build();
}
示例13: SingleConsumerContextImpl
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
this.serviceProvider = serviceProvider;
}
示例14: createInstance
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
@Override
public java.lang.AutoCloseable createInstance() {
// The services are provided via blueprint so retrieve then from the OSGi service registry for
// backwards compatibility.
final List<AutoCloseable> closeables = new ArrayList<>();
DOMNotificationService domNotificationService = newTracker(
DOMNotificationService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMNotificationPublishService domNotificationPublishService = newTracker(
DOMNotificationPublishService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMRpcService domRpcService = newTracker(
DOMRpcService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMRpcProviderService domRpcProvider = newTracker(
DOMRpcProviderService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMMountPointService mountService = newTracker(DOMMountPointService.class, closeables).
waitForService(WaitingServiceTracker.FIVE_MINUTES);
SchemaService globalSchemaService = newTracker(SchemaService.class, closeables).
waitForService(WaitingServiceTracker.FIVE_MINUTES);
final DOMDataBroker dataBroker = getAsyncDataBrokerDependency();
final ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
services.putInstance(DOMNotificationService.class, domNotificationService);
services.putInstance(DOMNotificationPublishService.class, domNotificationPublishService);
final SchemaService schemaService = getSchemaServiceImpl(globalSchemaService);
services.putInstance(SchemaService.class, schemaService);
services.putInstance(DOMDataBroker.class, dataBroker);
services.putInstance(DOMRpcService.class, domRpcService);
services.putInstance(DOMRpcProviderService.class, domRpcProvider);
services.putInstance(DOMMountPointService.class, mountService);
BrokerImpl broker = new BrokerImpl(domRpcService, domRpcProvider, services);
broker.setDeactivator(() -> {
for (AutoCloseable ac : closeables) {
try {
ac.close();
} catch (Exception e) {
LOG.warn("Exception while closing {}", ac, e);
}
}
});
return broker;
}
示例15: ServiceRegistry
import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public ServiceRegistry() {
this.services=MutableClassToInstanceMap.<Service>create();
this.builders=new LinkedHashMap<Class<?>, ServiceBuilder<?>>();
this.delegate=RuntimeDelegate.getInstance();
}