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

项目:FinanceAnalytics    文件:ComponentMapProvider.java   
@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;
}
项目:java-util-examples    文件:ClassToInstanceMapExample.java   
@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());
}
项目:bazel    文件:BuildConfiguration.java   
/**
 * 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;
}
项目:levelup-java-examples    文件:ClassToInstanceMapExample.java   
@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());
}
项目:rigel    文件:HighlightField.java   
private List<String> getHighlights(ClassToInstanceMap<FieldDataSource<?>> context) {
    QueryResponse response = context.getInstance(QueryResponseDataSource.class).get();
    Schema<?> schema = context.getInstance(SchemaDataSource.class).get();

    String docId = schema.id.getField().getValue(context);
    if (docId == null) {
        return null;
    }
    Map<String, Map<String, List<String>>> hilighting = response.getHighlighting();
    if (hilighting == null) {
        return null;
    }
    Map<String, List<String>> hilightingForDoc =  hilighting.get(docId);
    if (hilightingForDoc == null) {
        return null;
    }
    return hilightingForDoc.get(getFieldName());
}
项目:GitHub    文件:StaticEnvironment.java   
static <T extends Completable> T getInstance(Class<T> type, Supplier<T> supplier) {
  ClassToInstanceMap<Completable> components = state().components;
  @Nullable T instance = components.getInstance(type);
  if (instance == null) {
    instance = supplier.get();
    components.putInstance(type, instance);
  }
  return instance;
}
项目:guava-demo    文件:ClassToInstanceSample.java   
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);
}
项目:tensorics-core    文件:Coordinates.java   
/**
 * Creates a class to instance map, from the given coordinates. The map will contain the classes of the coordinates
 * as keys and the coordinates themselves as values. Duplicate keys (dimensions) are not allowed and will result in
 * an {@link IllegalArgumentException}.
 * 
 * @param coordinates the coordinates to be added to the map
 * @return an immutable map from dimensions (coordinate classes) to coordinate
 * @throws IllegalArgumentException if more than one coordinate per dimension are provided
 * @deprecated
 */
@Deprecated
public static <C> ClassToInstanceMap<C> mapOf(Iterable<? extends C> coordinates) {
    ImmutableClassToInstanceMap.Builder<C> coordinateBuilder = ImmutableClassToInstanceMap.builder();
    for (C coordinate : coordinates) {
        @SuppressWarnings("unchecked")
        Class<C> coordinateClass = (Class<C>) coordinate.getClass();
        coordinateBuilder.put(coordinateClass, coordinate);
    }
    return coordinateBuilder.build();
}
项目:tensorics-core    文件:ImmutableOptionRegistry.java   
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);
}
项目:tensorics-core    文件:ImmutableOptionRegistry.java   
private void addToMap(ClassToInstanceMap<T> mutableMap, Collection<T> toAdd) {
    for (T option : toAdd) {
        @SuppressWarnings("unchecked")
        Class<T> markerInterface = (Class<T>) option.getMarkerInterface();
        mutableMap.putInstance(markerInterface, option);
    }
}
项目:sette-tool    文件:SetteAnnotationUtils.java   
/**
 * 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;
}
项目:error-prone    文件:PlaceholderMethod.java   
static PlaceholderMethod create(
    CharSequence name,
    UType returnType,
    ImmutableMap<UVariableDecl, ImmutableClassToInstanceMap<Annotation>> parameters,
    ClassToInstanceMap<Annotation> annotations) {
  final boolean allowsIdentity = annotations.getInstance(Placeholder.class).allowsIdentity();
  final Class<? extends Matcher<? super ExpressionTree>> matchesClass =
      annotations.containsKey(Matches.class)
          ? UTemplater.getValue(annotations.getInstance(Matches.class))
          : null;
  final Class<? extends Matcher<? super ExpressionTree>> notMatchesClass =
      annotations.containsKey(NotMatches.class)
          ? UTemplater.getValue(annotations.getInstance(NotMatches.class))
          : null;
  final Predicate<Tree.Kind> allowedKinds =
      annotations.containsKey(OfKind.class)
          ? Predicates.<Tree.Kind>in(Arrays.asList(annotations.getInstance(OfKind.class).value()))
          : Predicates.<Tree.Kind>alwaysTrue();
  class PlaceholderMatcher implements Serializable, Matcher<ExpressionTree> {

    @Override
    public boolean matches(ExpressionTree t, VisitorState state) {
      try {
        return (allowsIdentity || !(t instanceof PlaceholderParamIdent))
            && (matchesClass == null || matchesClass.newInstance().matches(t, state))
            && (notMatchesClass == null || !notMatchesClass.newInstance().matches(t, state))
            && allowedKinds.apply(t.getKind());
      } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }
  }
  return new AutoValue_PlaceholderMethod(
      StringName.of(name),
      returnType,
      parameters,
      new PlaceholderMatcher(),
      ImmutableClassToInstanceMap.<Annotation, Annotation>copyOf(annotations));
}
项目:error-prone    文件:UnnecessarySetDefaultTest.java   
@Test
public void exhaustive() throws ReflectiveOperationException {
  Field f = ArbitraryInstances.class.getDeclaredField("DEFAULTS");
  f.setAccessible(true);
  ClassToInstanceMap<?> actual = (ClassToInstanceMap<?>) f.get(null);
  assertThat(UnnecessarySetDefault.DEFAULTS.keySet())
      .containsAnyIn(
          actual.keySet().stream().map(Class::getCanonicalName).collect(toImmutableList()));
}
项目:cloudata    文件:CloudataConnectorFactory.java   
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig) {
    checkNotNull(requiredConfig, "requiredConfig is null");
    checkNotNull(optionalConfig, "optionalConfig is null");

    try {
        // // A plugin is not required to use Guice; it is just very convenient
        // Bootstrap app = new Bootstrap(new JsonModule(), new ExampleModule(connectorId));
        //
        // Injector injector = app.strictConfig().doNotInitializeLogging()
        // .setRequiredConfigurationProperties(requiredConfig)
        // .setOptionalConfigurationProperties(optionalConfig).initialize();

        ClassToInstanceMap<Object> services = ImmutableClassToInstanceMap.builder()

        .put(ConnectorMetadata.class, new CloudataConnectorMetadata(connectorId, store))

        .put(ConnectorSplitManager.class, new CloudataSplitManager(nodeManager, connectorId))

        .put(ConnectorRecordSetProvider.class, new CloudataConnectorRecordSetProvider())

        .put(ConnectorHandleResolver.class, new CloudataConnectorHandleResolver()).build();

        CloudataConnector connector = new CloudataConnector(store, services);
        connectors.put(connectorId, connector);
        return connector;
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
项目:immutables    文件:StaticEnvironment.java   
static <T extends Completable> T getInstance(Class<T> type, Supplier<T> supplier) {
  ClassToInstanceMap<Completable> components = state().components;
  @Nullable T instance = components.getInstance(type);
  if (instance == null) {
    instance = supplier.get();
    components.putInstance(type, instance);
  }
  return instance;
}
项目:rigel    文件:FieldSet.java   
@Override
public void storeValue(Map<DataKey<?>, ? super Object> map, ClassToInstanceMap<FieldDataSource<?>> context) {
    R rawValue = field.getValue(context);
    if (eagerTransform) {
        map.put(this, formatRawValue(rawValue));
    } else {
        map.put(this, rawValue);
    }
}
项目:rigel    文件:ContentItemFactory.java   
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();
}
项目:rigel    文件:ContentItemFactory.java   
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();
}
项目:rigel    文件:ContentItemFactory.java   
public ImmutableList<ContentItem> fromResponse(QueryResponse response, FieldSet... additionalFields) {
    ClassToInstanceMap<FieldDataSource<?>> context = MutableClassToInstanceMap.create();
    context.put(QueryResponseDataSource.class, new QueryResponseDataSource(response));

    Builder<ContentItem> builder = ImmutableList.builder();
    for(SolrDocument doc : response.getResults()) {
        ContentItem.Schema<?> schema = getSchemaForDocument(doc);
        context.put(SchemaDataSource.class, new SchemaDataSource(schema));
        context.put(SolrDocDataSource.class, new SolrDocDataSource(doc));
        builder.add(buildItem(schema, context, additionalFields));
    }
    return builder.build();
}
项目:rigel    文件:ContentItemFactory.java   
public ImmutableList<ContentItem> fromDocumentList(SolrDocumentList list, FieldSet... additionalFields) {
    ClassToInstanceMap<FieldDataSource<?>> context = MutableClassToInstanceMap.create();
    Builder<ContentItem> builder = ImmutableList.builder();
    for(SolrDocument doc : list) {
        ContentItem.Schema<?> schema = getSchemaForDocument(doc);
        context.put(SchemaDataSource.class, new SchemaDataSource(schema));
        context.put(SolrDocDataSource.class, new SolrDocDataSource(doc));
        builder.add(buildItem(schema, context, additionalFields));
    }
    return builder.build();
}
项目:rigel    文件:HighlightField.java   
@Override
public String getValue(ClassToInstanceMap<FieldDataSource<?>> context) {
    List<String> highlights = getHighlights(context);
    if (highlights == null || highlights.size() == 0) {
        return null;
    }
    return highlights.get(0);
}
项目:guava-mock    文件:ArbitraryInstancesTest.java   
public void testGet_collections() {
  assertEquals(ImmutableSet.of().iterator(), ArbitraryInstances.get(Iterator.class));
  assertFalse(ArbitraryInstances.get(PeekingIterator.class).hasNext());
  assertFalse(ArbitraryInstances.get(ListIterator.class).hasNext());
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Iterable.class));
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Set.class));
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(ImmutableSet.class));
  assertEquals(ImmutableSortedSet.of(), ArbitraryInstances.get(SortedSet.class));
  assertEquals(ImmutableSortedSet.of(), ArbitraryInstances.get(ImmutableSortedSet.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(Collection.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(ImmutableCollection.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(List.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(ImmutableList.class));
  assertEquals(ImmutableMap.of(), ArbitraryInstances.get(Map.class));
  assertEquals(ImmutableMap.of(), ArbitraryInstances.get(ImmutableMap.class));
  assertEquals(ImmutableSortedMap.of(), ArbitraryInstances.get(SortedMap.class));
  assertEquals(ImmutableSortedMap.of(), ArbitraryInstances.get(ImmutableSortedMap.class));
  assertEquals(ImmutableMultiset.of(), ArbitraryInstances.get(Multiset.class));
  assertEquals(ImmutableMultiset.of(), ArbitraryInstances.get(ImmutableMultiset.class));
  assertTrue(ArbitraryInstances.get(SortedMultiset.class).isEmpty());
  assertEquals(ImmutableMultimap.of(), ArbitraryInstances.get(Multimap.class));
  assertEquals(ImmutableMultimap.of(), ArbitraryInstances.get(ImmutableMultimap.class));
  assertTrue(ArbitraryInstances.get(SortedSetMultimap.class).isEmpty());
  assertEquals(ImmutableTable.of(), ArbitraryInstances.get(Table.class));
  assertEquals(ImmutableTable.of(), ArbitraryInstances.get(ImmutableTable.class));
  assertTrue(ArbitraryInstances.get(RowSortedTable.class).isEmpty());
  assertEquals(ImmutableBiMap.of(), ArbitraryInstances.get(BiMap.class));
  assertEquals(ImmutableBiMap.of(), ArbitraryInstances.get(ImmutableBiMap.class));
  assertTrue(ArbitraryInstances.get(ImmutableClassToInstanceMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ClassToInstanceMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ListMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ImmutableListMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(SetMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ImmutableSetMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(MapDifference.class).areEqual());
  assertTrue(ArbitraryInstances.get(SortedMapDifference.class).areEqual());
  assertEquals(Range.all(), ArbitraryInstances.get(Range.class));
  assertTrue(ArbitraryInstances.get(NavigableSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(NavigableMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(LinkedList.class).isEmpty());
  assertTrue(ArbitraryInstances.get(Deque.class).isEmpty());
  assertTrue(ArbitraryInstances.get(Queue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(PriorityQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(BitSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(TreeSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(TreeMap.class).isEmpty());
  assertFreshInstanceReturned(
      LinkedList.class, Deque.class, Queue.class, PriorityQueue.class, BitSet.class,
      TreeSet.class, TreeMap.class);
}
项目:googles-monorepo-demo    文件:ArbitraryInstancesTest.java   
public void testGet_collections() {
  assertEquals(ImmutableSet.of().iterator(), ArbitraryInstances.get(Iterator.class));
  assertFalse(ArbitraryInstances.get(PeekingIterator.class).hasNext());
  assertFalse(ArbitraryInstances.get(ListIterator.class).hasNext());
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Iterable.class));
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Set.class));
  assertEquals(ImmutableSet.of(), ArbitraryInstances.get(ImmutableSet.class));
  assertEquals(ImmutableSortedSet.of(), ArbitraryInstances.get(SortedSet.class));
  assertEquals(ImmutableSortedSet.of(), ArbitraryInstances.get(ImmutableSortedSet.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(Collection.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(ImmutableCollection.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(List.class));
  assertEquals(ImmutableList.of(), ArbitraryInstances.get(ImmutableList.class));
  assertEquals(ImmutableMap.of(), ArbitraryInstances.get(Map.class));
  assertEquals(ImmutableMap.of(), ArbitraryInstances.get(ImmutableMap.class));
  assertEquals(ImmutableSortedMap.of(), ArbitraryInstances.get(SortedMap.class));
  assertEquals(ImmutableSortedMap.of(), ArbitraryInstances.get(ImmutableSortedMap.class));
  assertEquals(ImmutableMultiset.of(), ArbitraryInstances.get(Multiset.class));
  assertEquals(ImmutableMultiset.of(), ArbitraryInstances.get(ImmutableMultiset.class));
  assertTrue(ArbitraryInstances.get(SortedMultiset.class).isEmpty());
  assertEquals(ImmutableMultimap.of(), ArbitraryInstances.get(Multimap.class));
  assertEquals(ImmutableMultimap.of(), ArbitraryInstances.get(ImmutableMultimap.class));
  assertTrue(ArbitraryInstances.get(SortedSetMultimap.class).isEmpty());
  assertEquals(ImmutableTable.of(), ArbitraryInstances.get(Table.class));
  assertEquals(ImmutableTable.of(), ArbitraryInstances.get(ImmutableTable.class));
  assertTrue(ArbitraryInstances.get(RowSortedTable.class).isEmpty());
  assertEquals(ImmutableBiMap.of(), ArbitraryInstances.get(BiMap.class));
  assertEquals(ImmutableBiMap.of(), ArbitraryInstances.get(ImmutableBiMap.class));
  assertTrue(ArbitraryInstances.get(ImmutableClassToInstanceMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ClassToInstanceMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ListMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ImmutableListMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(SetMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ImmutableSetMultimap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(MapDifference.class).areEqual());
  assertTrue(ArbitraryInstances.get(SortedMapDifference.class).areEqual());
  assertEquals(Range.all(), ArbitraryInstances.get(Range.class));
  assertTrue(ArbitraryInstances.get(NavigableSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(NavigableMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(LinkedList.class).isEmpty());
  assertTrue(ArbitraryInstances.get(Deque.class).isEmpty());
  assertTrue(ArbitraryInstances.get(Queue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(PriorityQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(BitSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(TreeSet.class).isEmpty());
  assertTrue(ArbitraryInstances.get(TreeMap.class).isEmpty());
  assertFreshInstanceReturned(
      LinkedList.class, Deque.class, Queue.class, PriorityQueue.class, BitSet.class,
      TreeSet.class, TreeMap.class);
}
项目:hashsdn-controller    文件:BrokerImpl.java   
public BrokerImpl(final DOMRpcRouter router,final ClassToInstanceMap<BrokerService> services) {
    this(router, router, services);
}
项目:hashsdn-controller    文件:BrokerImpl.java   
public BrokerImpl(final DOMRpcService rpcService, final DOMRpcProviderService rpcProvider,
        final ClassToInstanceMap<BrokerService> services) {
    this.rpcService = Preconditions.checkNotNull(rpcService, "DOMRpcService must not be null");
    this.rpcProvider = Preconditions.checkNotNull(rpcProvider, "DOMRpcProviderService must not be null");
    this.services = ImmutableClassToInstanceMap.copyOf(services);
}
项目:hashsdn-controller    文件:SimpleDOMMountPoint.java   
public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
    return new SimpleDOMMountPoint(identifier, services, ctx);
}
项目:hashsdn-controller    文件:SimpleDOMMountPoint.java   
private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
    this.identifier = identifier;
    this.services = ImmutableClassToInstanceMap.copyOf(services);
    this.schemaContext = ctx;
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public static ConsumerContext createConsumerContext(BindingAwareConsumer consumer,
        ClassToInstanceMap<BindingAwareService> serviceProvider) {
    checkNotNull(consumer,"Consumer should not be null");
    checkNotNull(serviceProvider,"Service map should not be null");
    return new SingleConsumerContextImpl(serviceProvider);
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public static ProviderContext createProviderContext(BindingAwareProvider provider,
        ClassToInstanceMap<BindingAwareService> serviceProvider) {
    checkNotNull(provider,"Provider should not be null");
    checkNotNull(serviceProvider,"Service map should not be null");
    return new SingleProviderContextImpl(serviceProvider);
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public static ConsumerContext createConsumerContextAndInitialize(BindingAwareConsumer consumer,
        ClassToInstanceMap<BindingAwareService> serviceProvider) {
    ConsumerContext context = createConsumerContext(consumer, serviceProvider);
    consumer.onSessionInitialized(context);
    return context;
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
        ClassToInstanceMap<BindingAwareService> serviceProvider) {
    ProviderContext context = createProviderContext(provider, serviceProvider);
    provider.onSessionInitiated(context);
    return context;
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
    this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
    this.serviceProvider = serviceProvider;
}
项目:hashsdn-controller    文件:BindingContextUtils.java   
public SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
    super(serviceProvider);
}
项目:hashsdn-controller    文件:BindingDOMAdapterBuilder.java   
@Override
protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
    Preconditions.checkState(codec != null);
    return createInstance(codec,delegates);
}
项目:hashsdn-controller    文件:BindingDOMDataBrokerAdapter.java   
@Override
protected DataBroker createInstance(final BindingToNormalizedNodeCodec codec,
        final ClassToInstanceMap<DOMService> delegates) {
    final DOMDataBroker domDataBroker = delegates.getInstance(DOMDataBroker.class);
    return new BindingDOMDataBrokerAdapter(domDataBroker, codec);
}
项目:hashsdn-controller    文件:BindingDOMRpcServiceAdapter.java   
@Override
protected RpcConsumerRegistry createInstance(final BindingToNormalizedNodeCodec codec,
        final ClassToInstanceMap<DOMService> delegates) {
    final DOMRpcService domRpc  = delegates.getInstance(DOMRpcService.class);
    return new BindingDOMRpcServiceAdapter(domRpc  , codec);
}
项目:hashsdn-controller    文件:BindingDOMNotificationPublishServiceAdapter.java   
@Override
protected NotificationPublishService createInstance(final BindingToNormalizedNodeCodec codec,
        final ClassToInstanceMap<DOMService> delegates) {
    final DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class);
    return new BindingDOMNotificationPublishServiceAdapter(codec, domPublish);
}
项目:hashsdn-controller    文件:BindingDOMNotificationServiceAdapter.java   
@Override
protected NotificationService createInstance(final BindingToNormalizedNodeCodec codec,
        final ClassToInstanceMap<DOMService> delegates) {
    final DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
    return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification);
}
项目:hashsdn-controller    文件:DomBrokerImplModule.java   
@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;
}
项目:FinanceAnalytics    文件:DiscountingMulticurveBundleFnTest.java   
@BeforeClass
public void init() throws IOException {
  //builds graph, initializing mocks

  ClassToInstanceMap<Object> mocks = MockUtils.mocks(MOCK_CLASSES);

  initConfigSource(mocks.getInstance(ConfigSource.class));
  initConventionSource(mocks.getInstance(ConventionSource.class));
  initSecuritySource(mocks.getInstance(SecuritySource.class));
  initRegionSource(mocks.getInstance(RegionSource.class));

  mocks.putInstance(RootFinderConfiguration.class, ROOT_FINDER_CONFIG);
  mocks.putInstance(HolidaySource.class, new WeekendHolidaySource());

  mocks.putInstance(LegalEntitySource.class, mock(LegalEntitySource.class));
  mocks.putInstance(ConventionBundleSource.class, mock(ConventionBundleSource.class));
  ComponentMap components = ComponentMap.of(mocks);

  FunctionModelConfig config = config(
      arguments(
          function(DefaultDiscountingMulticurveBundleFn.class,
                   argument("impliedCurveNames", StringSet.of("Implied Deposit Curve KRW"))),
          function(DefaultCurveNodeConverterFn.class,
                   argument("timeSeriesDuration", RetrievalPeriod.of(Period.ofDays(1))))),
      implementations(CurveDefinitionFn.class, DefaultCurveDefinitionFn.class,
                      CurveSpecificationFn.class, DefaultCurveSpecificationFn.class,
                      CurveSpecificationMarketDataFn.class, DefaultCurveSpecificationMarketDataFn.class,
                      CurveNodeConverterFn.class, DefaultCurveNodeConverterFn.class,
                      FXMatrixFn.class, DefaultFXMatrixFn.class,
                      DiscountingMulticurveBundleFn.class, DefaultDiscountingMulticurveBundleFn.class,
                      DiscountingMulticurveBundleResolverFn.class, DefaultDiscountingMulticurveBundleResolverFn.class,
                      MarketDataFn.class, DefaultMarketDataFn.class));

  _multicurveBundleFn = FunctionModel.build(DiscountingMulticurveBundleResolverFn.class, config, components);

  ZonedDateTime valuationDate = ZonedDateTime.of(2014, 1, 10, 11, 0, 0, 0, ZoneId.of("America/Chicago"));
  MarketDataBundle marketDataBundle =
      MarketDataResourcesLoader.getPreloadedBundle(
          "/regression/curve_testing/usdMarketQuotes.properties",
                                                   "Ticker");

  _environment = new SimpleEnvironment(valuationDate, marketDataBundle);

  VersionCorrectionProvider vcProvider = new TestVersionCorrectionProvider();

  ServiceContext serviceContext = ServiceContext.of(mocks).with(VersionCorrectionProvider.class, vcProvider);
  ThreadLocalServiceContext.init(serviceContext);

  _usdDiscountingCCC = createUSDCurveConstructionConfig();
}