本文整理汇总了Java中com.google.common.collect.ImmutableMap.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于com.google.common.collect.ImmutableMap包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: viewUserOpenSteps
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
/**
* 获取未完成的steps
*
* @param companyId
* @param userId
* @return
*/
@RequestMapping(value = "/{companyId}/user/{userId}/uncompletedSteps", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class, UserChecking.class })
@ResponseBody
public Map<String, Object> viewUserOpenSteps(@PathVariable int companyId, @PathVariable int userId) {
Builder<String, Object> builder = ImmutableMap.builder();
Map<Integer, String> projectIdToName = getProjectIdAndNameByCompanyId(companyId);
builder.put("projectsName", projectIdToName);
List<Integer> projectList = getProjectListOfCurrentUser(companyId);
Map<Integer, List<Step>> steps = stepService.getOpenStepsByUser(userId, projectList);
Map<Integer, List<StepDTO>> stepsDto = makeUserUncompletedStepsMapSerilizable(steps);
builder.put("uncompletedSteps", stepsDto);
Map<Integer, List<User>> users = userService.getAllProjectUsersInCompany(companyId);
Map<Integer, List<UserDTO>> userDtos = makeUserUncompletedTodosMapSerilizable(users);
builder.put("userDtos", userDtos);
UserDTO userDto = UserTransform.userToUserDTO(userService.getById(userId));
builder.put("user", userDto);
return builder.build();
}
示例2: buildModObjectList
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例3: serialize
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
super.serialize(builder);
if (hasTitle()) {
builder.put(BOOK_TITLE.BUKKIT, title);
}
if (hasAuthor()) {
builder.put(BOOK_AUTHOR.BUKKIT, author);
}
if (hasPages()) {
builder.put(BOOK_PAGES.BUKKIT, pages);
}
return builder;
}
示例4: testBuilderPutAll
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
public void testBuilderPutAll() {
Map<String, Integer> toPut = new LinkedHashMap<String, Integer>();
toPut.put("one", 1);
toPut.put("two", 2);
toPut.put("three", 3);
Map<String, Integer> moreToPut = new LinkedHashMap<String, Integer>();
moreToPut.put("four", 4);
moreToPut.put("five", 5);
ImmutableMap<String, Integer> map = new Builder<String, Integer>()
.putAll(toPut)
.putAll(moreToPut)
.build();
assertMapEquals(map,
"one", 1, "two", 2, "three", 3, "four", 4, "five", 5);
}
示例5: initContributions
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
private Supplier<Map<String, WorkingSetManager>> initContributions() {
return memoize(() -> {
if (!isRunning()) {
return emptyMap();
}
final Builder<String, WorkingSetManager> builder = ImmutableMap.builder();
final IConfigurationElement[] elements = getExtensionRegistry()
.getConfigurationElementsFor(EXTENSION_POINT_ID);
for (final IConfigurationElement element : elements) {
try {
final WorkingSetManager manager = (WorkingSetManager) element
.createExecutableExtension(CLASS_ATTRIBUTE);
injector.injectMembers(manager);
builder.put(manager.getId(), manager);
} catch (final CoreException e) {
LOGGER.error("Error while trying to instantiate working set manager.", e);
}
}
return builder.build();
});
}
示例6: testBuilder_withMutableEntry
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
public void testBuilder_withMutableEntry() {
ImmutableMap.Builder<String, Integer> builder =
new Builder<String, Integer>();
final StringHolder holder = new StringHolder();
holder.string = "one";
Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
@Override public String getKey() {
return holder.string;
}
@Override public Integer getValue() {
return 1;
}
};
builder.put(entry);
holder.string = "two";
assertMapEquals(builder.build(), "one", 1);
}
示例7: JobMetrics
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
public JobMetrics(Job job, String bytesReplicatedKey) {
Builder<String, Long> builder = ImmutableMap.builder();
if (job != null) {
Counters counters;
try {
counters = job.getCounters();
} catch (IOException e) {
throw new CircusTrainException("Unable to get counters from job.", e);
}
if (counters != null) {
for (CounterGroup group : counters) {
for (Counter counter : group) {
builder.put(DotJoiner.join(group.getName(), counter.getName()), counter.getValue());
}
}
}
}
metrics = builder.build();
Long bytesReplicatedValue = metrics.get(bytesReplicatedKey);
if (bytesReplicatedValue != null) {
bytesReplicated = bytesReplicatedValue;
} else {
bytesReplicated = 0L;
}
}
示例8: mapGraphValue
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
@Override
public Object mapGraphValue(@NonNull RefProperty schema,
@NonNull GraphEntityContext graphEntityContext,
@NonNull ValueContext valueContext,
@NonNull SchemaMapperAdapter schemaMapperAdapter) {
Model refModel = graphEntityContext.getSwaggerDefinitions().get(schema.getSimpleRef());
if (refModel == null) {
throw new SchemaMapperRuntimeException(String.format(
"Unable to resolve reference to swagger model: '%s'.", schema.getSimpleRef()));
}
Builder<String, Object> builder = ImmutableMap.builder();
refModel.getProperties().forEach((propKey, propValue) -> builder.put(propKey,
Optional.fromNullable(schemaMapperAdapter.mapGraphValue(propValue, graphEntityContext,
valueContext, schemaMapperAdapter))));
return builder.build();
}
示例9: getPrivilegesForObjects
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
@Override
@Transactional
public <T> Map<T, Map<String, Boolean>> getPrivilegesForObjects(Collection<String> privileges,
Collection<T> domainObjs)
{
if( CurrentUser.getUserState().isSystem() )
{
Builder<String, Boolean> builder = ImmutableMap.builder();
for( String priv : privileges )
{
builder.put(priv, true);
}
ImmutableMap<String, Boolean> allPrivs = builder.build();
Builder<T, Map<String, Boolean>> domainBuilder = ImmutableMap.builder();
for( T t : domainObjs )
{
domainBuilder.put(t, allPrivs);
}
return domainBuilder.build();
}
return getObjectToPrivileges(privileges, domainObjs);
}
示例10: getDependents
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
private synchronized List<PluginBeanLocator> getDependents()
{
if( dependentLocators == null )
{
Set<String> seenPlugins = new HashSet<String>();
PluginDescriptor descriptor = extension.getDeclaringPluginDescriptor();
ImmutableList.Builder<PluginBeanLocator> builder = ImmutableList.builder();
for( PluginPrerequisite preRequisite : descriptor.getPrerequisites() )
{
String depId = preRequisite.getPluginId();
getSecondLevelDependents(depId, seenPlugins, builder);
}
dependentLocators = builder.build();
}
return dependentLocators;
}
示例11: getSecondLevelDependents
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
private void getSecondLevelDependents(String pluginId, Set<String> seenPlugins,
ImmutableList.Builder<PluginBeanLocator> builder)
{
if( seenPlugins.contains(pluginId) )
{
return;
}
seenPlugins.add(pluginId);
PluginBeanLocator beanLocator = privatePluginService.getBeanLocator(pluginId);
if( beanLocator != null )
{
builder.add(beanLocator);
}
PluginDescriptor descriptor = privatePluginService.getPluginDescriptor(pluginId);
Collection<PluginPrerequisite> prerequisites = descriptor.getPrerequisites();
for( PluginPrerequisite pluginPrerequisite : prerequisites )
{
if( pluginPrerequisite.isExported() )
{
getSecondLevelDependents(pluginPrerequisite.getPluginId(), seenPlugins, builder);
}
}
}
示例12: getBeanCheckers
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
protected synchronized List<BeanChecker> getBeanCheckers()
{
if( this.beanCheckers == null )
{
Collection<Extension> checkers = privatePluginService.getConnectedExtensions(PLUGIN_ID, "beanChecker");
ImmutableList.Builder<BeanChecker> builder = ImmutableList.builder();
for( Extension extension : checkers )
{
BeanChecker beanChecker = (BeanChecker) privatePluginService.getBean(
extension.getDeclaringPluginDescriptor(), extension.getParameter("class").valueAsString());
builder.add(beanChecker);
}
this.beanCheckers = builder.build();
}
return beanCheckers;
}
示例13: setupBeanLocators
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
private synchronized void setupBeanLocators()
{
Builder<String, GuiceBeanLocator> builder = new ImmutableMap.Builder<String, GuiceBeanLocator>();
PluginRegistry registry = getManager().getRegistry();
ExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, "module"); //$NON-NLS-1$
Collection<Extension> extensions = point.getConnectedExtensions();
for( Extension extension : extensions )
{
String extPluginId = extension.getDeclaringPluginDescriptor().getId();
GuiceBeanLocator locator = guiceLocators.get(extPluginId);
if( locator == null )
{
locator = new GuiceBeanLocator(extPluginId, extension);
}
privatePluginService.setPluginBeanLocator(extPluginId, locator);
builder.put(extPluginId, locator);
}
guiceLocators = builder.build();
}
示例14: buildModObjectList
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
示例15: remove
import com.google.common.collect.ImmutableMap.Builder; //导入依赖的package包/类
DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcs) {
if (rpcs.isEmpty()) {
return this;
}
// First decompose the identifiers to a multimap
final ListMultimap<SchemaPath, YangInstanceIdentifier> toRemove = decomposeIdentifiers(rpcs);
// Now iterate over existing entries, modifying them as appropriate...
final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();
for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : this.rpcs.entrySet()) {
final List<YangInstanceIdentifier> removed = new ArrayList<>(toRemove.removeAll(e.getKey()));
if (!removed.isEmpty()) {
final AbstractDOMRpcRoutingTableEntry ne = e.getValue().remove(implementation, removed);
if (ne != null) {
b.put(e.getKey(), ne);
}
} else {
b.put(e);
}
}
// All done, whatever is in toRemove, was not there in the first place
return new DOMRpcRoutingTable(b.build(), schemaContext);
}