本文整理汇总了Java中com.google.common.collect.ImmutableClassToInstanceMap.builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableClassToInstanceMap.builder方法的具体用法?Java ImmutableClassToInstanceMap.builder怎么用?Java ImmutableClassToInstanceMap.builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableClassToInstanceMap
的用法示例。
在下文中一共展示了ImmutableClassToInstanceMap.builder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotationMap
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static ImmutableClassToInstanceMap<Annotation> annotationMap(Symbol symbol) {
ImmutableClassToInstanceMap.Builder<Annotation> builder = ImmutableClassToInstanceMap.builder();
for (Compound compound : symbol.getAnnotationMirrors()) {
Name qualifiedAnnotationType =
((TypeElement) compound.getAnnotationType().asElement()).getQualifiedName();
try {
Class<? extends Annotation> annotationClazz =
Class.forName(qualifiedAnnotationType.toString()).asSubclass(Annotation.class);
builder.put((Class) annotationClazz,
AnnotationProxyMaker.generateAnnotation(compound, annotationClazz));
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Unrecognized annotation type", e);
}
}
return builder.build();
}
示例2: annotationMap
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static ImmutableClassToInstanceMap<Annotation> annotationMap(Symbol symbol) {
ImmutableClassToInstanceMap.Builder<Annotation> builder = ImmutableClassToInstanceMap.builder();
for (Compound compound : symbol.getAnnotationMirrors()) {
Name qualifiedAnnotationType =
((TypeElement) compound.getAnnotationType().asElement()).getQualifiedName();
try {
Class<? extends Annotation> annotationClazz =
Class.forName(qualifiedAnnotationType.toString()).asSubclass(Annotation.class);
builder.put(
(Class) annotationClazz,
AnnotationProxyMaker.generateAnnotation(compound, annotationClazz));
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Unrecognized annotation type", e);
}
}
return builder.build();
}
示例3: start
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
public void start() {
checkState(controllerRoot == null, "Binding Aware Broker was already started.");
LOG.info("Starting Binding Aware Broker: {}", identifier);
controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker());
final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap
.builder();
consBuilder.put(NotificationService.class, getRoot());
consBuilder.put(RpcConsumerRegistry.class, getRoot());
if (dataBroker != null) {
consBuilder.put(DataBroker.class, dataBroker);
}
consBuilder.put(MountPointService.class, mountService);
supportedConsumerServices = consBuilder.build();
final ImmutableClassToInstanceMap.Builder<BindingAwareService> provBuilder = ImmutableClassToInstanceMap
.builder();
provBuilder.putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot())
.put(RpcProviderRegistry.class, getRoot());
if (notificationPublishService != null) {
provBuilder.put(NotificationPublishService.class, notificationPublishService);
}
supportedProviderServices = provBuilder.build();
}
示例4: mapOf
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
/**
* 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();
}
示例5: annotations
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ImmutableClassToInstanceMap<Annotation> annotations() {
ImmutableClassToInstanceMap.Builder<Annotation> builder = ImmutableClassToInstanceMap.builder();
for (Annotation annotation : checker().getClass().getDeclaredAnnotations()) {
builder.put((Class) annotation.annotationType(), annotation);
}
return builder.build();
}
示例6: getAttachments
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
private ImmutableClassToInstanceMap<Object> getAttachments(IStrategoTerm term) {
Builder<Object> b = ImmutableClassToInstanceMap.builder();
TermOrigin.get(term).ifPresent(origin -> {
b.put(TermOrigin.class, origin);
});
StrategoTermIndices.get(term).ifPresent(termIndex -> {
b.put(TermIndex.class, termIndex);
});
b.put(StrategoAnnotations.class, ImmutableStrategoAnnotations.of(term.getAnnotations()));
return b.build();
}
示例7: getFieldValue
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
/**
* Helper method to wrap the solr doc up in a context & get the value using the field
*/
private <R> R getFieldValue(Field<R> field, SolrDocument doc) {
ImmutableClassToInstanceMap.Builder<FieldDataSource<?>> context = ImmutableClassToInstanceMap.builder();
context.put(SolrDocDataSource.class, new SolrDocDataSource(doc));
return field.getValue(context.build());
}