當前位置: 首頁>>代碼示例>>Java>>正文


Java MutableClassToInstanceMap類代碼示例

本文整理匯總了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;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:27,代碼來源:ComponentMapProvider.java

示例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());
}
 
開發者ID:wq19880601,項目名稱:java-util-examples,代碼行數:17,代碼來源:ClassToInstanceMapExample.java

示例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;
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:24,代碼來源:BuildConfiguration.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:StaticEnvironment.java

示例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();
}
 
開發者ID:apache,項目名稱:beam,代碼行數:10,代碼來源:ProxyInvocationHandler.java

示例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);
}
 
開發者ID:alxsimo,項目名稱:guava-demo,代碼行數:11,代碼來源:ClassToInstanceSample.java

示例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;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:14,代碼來源:MockUtils.java

示例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);
}
 
開發者ID:tensorics,項目名稱:tensorics-core,代碼行數:10,代碼來源:ImmutableOptionRegistry.java

示例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;
}
 
開發者ID:SETTE-Testing,項目名稱:sette-tool,代碼行數:18,代碼來源:SetteAnnotationUtils.java

示例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>();
}
 
開發者ID:saiba,項目名稱:OpenBMLParser,代碼行數:12,代碼來源:BehaviourBlock.java

示例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();
}
 
開發者ID:semantico,項目名稱:rigel,代碼行數:13,代碼來源:ContentItemFactory.java

示例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();
}
 
開發者ID:semantico,項目名稱:rigel,代碼行數:11,代碼來源:ContentItemFactory.java

示例13: SingleConsumerContextImpl

import com.google.common.collect.MutableClassToInstanceMap; //導入依賴的package包/類
public SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
    this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
    this.serviceProvider = serviceProvider;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:5,代碼來源:BindingContextUtils.java

示例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;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:55,代碼來源:DomBrokerImplModule.java

示例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();
}
 
開發者ID:ldp4j,項目名稱:ldp4j,代碼行數:6,代碼來源:ServiceRegistry.java


注:本文中的com.google.common.collect.MutableClassToInstanceMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。