本文整理汇总了Java中com.google.common.collect.ImmutableClassToInstanceMap.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableClassToInstanceMap.copyOf方法的具体用法?Java ImmutableClassToInstanceMap.copyOf怎么用?Java ImmutableClassToInstanceMap.copyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableClassToInstanceMap
的用法示例。
在下文中一共展示了ImmutableClassToInstanceMap.copyOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImmutableOptionRegistry
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的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);
}
示例2: create
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
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));
}
示例3: BrokerImpl
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
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);
}
示例4: SimpleDOMMountPoint
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
this.identifier = identifier;
this.services = ImmutableClassToInstanceMap.copyOf(services);
this.schemaContext = ctx;
}
示例5: CloudataConnector
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
public CloudataConnector(StructuredStore store, Map<Class<?>, ?> services) {
this.store = store;
this.services = ImmutableClassToInstanceMap.copyOf(services);
}
示例6: of
import com.google.common.collect.ImmutableClassToInstanceMap; //导入方法依赖的package包/类
/**
* Creates a new service context using the provided map to populate the service registry.
*
* @param services a map of type to service-providing objects, not null
* @return a populated service context, not null
*/
public static ServiceContext of(Map<Class<?>, Object> services) {
ArgumentChecker.noNulls(services, "services");
return new ServiceContext(ImmutableClassToInstanceMap.copyOf(services));
}