项目:onboard
文件:UserAPIController.java
/**
* 获取未完成的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();
}
项目:CauldronGit
文件:LoadController.java
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();
}
@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;
}
项目:guava-libraries
文件:ImmutableMapTest.java
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);
}
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();
});
}
@Override
Builder<String,pages);
}
return builder;
}
项目:guava-mock
文件:ImmutableMapTest.java
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(),1);
}
项目:guava-mock
文件:ImmutableMapTest.java
public void testBuilderPutAll() {
Map<String,5);
}
项目:circus-train
文件:JobMetrics.java
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;
}
}
项目:dotwebstack-framework
文件:RefSchemaMapper.java
@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();
}
项目:Equella
文件:TLEAclManagerImpl.java
@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,Boolean>> domainBuilder = ImmutableMap.builder();
for( T t : domainObjs )
{
domainBuilder.put(t,allPrivs);
}
return domainBuilder.build();
}
return getobjectToPrivileges(privileges,domainObjs);
}
项目:Equella
文件:GuicePlugin.java
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;
}
项目:Equella
文件:GuicePlugin.java
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(),builder);
}
}
}
项目:Equella
文件:GuicePlugin.java
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;
}
项目:Equella
文件:GuicePlugin.java
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();
}
public void testBuilder_withMutableEntry() {
ImmutableMap.Builder<String,1);
}
public void testBuilderPutAll() {
Map<String,5);
}
项目:CustomWorldGen
文件:LoadController.java
public ImmutableBiMap<ModContainer,Object> builder = ImmutableBiMap.builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc,new RuntimeException());
}
}
}
return builder.build();
}
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);
}
/**
*
* @param implementation
* @param newRpcs List of new RPCs,must be mutable
* @return
*/
final AbstractDomrpcRoutingTableEntry add(final DomrpcImplementation implementation,final List<YangInstanceIdentifier> newRpcs) {
final Builder<YangInstanceIdentifier,List<DomrpcImplementation>> vb = ImmutableMap.builder();
for (final Entry<YangInstanceIdentifier,List<DomrpcImplementation>> ve : impls.entrySet()) {
if (newRpcs.remove(ve.getKey())) {
final List<DomrpcImplementation> i = new ArrayList<>(ve.getValue().size() + 1);
i.addAll(ve.getValue());
i.add(implementation);
// New implementation is at the end,this will move it to be the last among implementations
// with equal cost -- relying on sort() being stable.
i.sort(Comparator.comparingLong(DomrpcImplementation::invocationCost));
vb.put(ve.getKey(),i);
} else {
vb.put(ve);
}
}
for(final YangInstanceIdentifier ii : newRpcs) {
final List<DomrpcImplementation> impl = new ArrayList<>(1);
impl.add(implementation);
vb.put(ii,impl);
}
return newInstance(vb.build());
}
final AbstractDomrpcRoutingTableEntry remove(final DomrpcImplementation implementation,final List<YangInstanceIdentifier> removed) {
final Builder<YangInstanceIdentifier,List<DomrpcImplementation>> ve : impls.entrySet()) {
if (removed.remove(ve.getKey())) {
final List<DomrpcImplementation> i = new ArrayList<>(ve.getValue());
i.remove(implementation);
// We Could trimToSize(),but that may perform another copy just to get rid
// of a single element. That is probably not worth the trouble.
if (!i.isEmpty()) {
vb.put(ve.getKey(),i);
}
} else {
vb.put(ve);
}
}
final Map<YangInstanceIdentifier,List<DomrpcImplementation>> v = vb.build();
return v.isEmpty() ? null : newInstance(v);
}
@Override
public void readExternal(final ObjectInput in) throws IOException,ClassNotFoundException {
final int MetaSize = in.readInt();
Preconditions.checkArgument(MetaSize >= 0,"Invalid negative Metadata map length %s",MetaSize);
// Default pre-allocate is 4,which should be fine
final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>,ShardDataTreeSnapshotMetadata<?>>
MetaBuilder = ImmutableMap.builder();
for (int i = 0; i < MetaSize; ++i) {
final ShardDataTreeSnapshotMetadata<?> m = (ShardDataTreeSnapshotMetadata<?>) in.readobject();
if (m != null) {
MetaBuilder.put(m.getType(),m);
} else {
LOG.warn("Skipping null Metadata");
}
}
Metadata = MetaBuilder.build();
rootNode = Verify.verifyNotNull(SerializationUtils.deserializenormalizednode(in));
}
项目:Mastering-Mesos
文件:SingularityClient.java
private void addQueryParams(HttpRequest.Builder requestBuilder,Object> queryParams) {
for (Entry<String,Object> queryParamEntry : queryParams.entrySet()) {
if (queryParamEntry.getValue() instanceof String) {
requestBuilder.setQueryParam(queryParamEntry.getKey()).to((String) queryParamEntry.getValue());
} else if (queryParamEntry.getValue() instanceof Integer) {
requestBuilder.setQueryParam(queryParamEntry.getKey()).to((Integer) queryParamEntry.getValue());
} else if (queryParamEntry.getValue() instanceof Long) {
requestBuilder.setQueryParam(queryParamEntry.getKey()).to((Long) queryParamEntry.getValue());
} else if (queryParamEntry.getValue() instanceof Boolean) {
requestBuilder.setQueryParam(queryParamEntry.getKey()).to((Boolean) queryParamEntry.getValue());
} else {
throw new RuntimeException(String.format("The type '%s' of query param %s is not supported. Only String,long,int and boolean values are supported",queryParamEntry.getValue().getClass().getName(),queryParamEntry.getKey()));
}
}
}
项目:Mastering-Mesos
文件:SingularityClient.java
/**
* Retrieve a paged list of updates for a particular {@link SingularityRequest}
*
* @param requestId
* Request ID to look up
* @param count
* Number of items to return per page
* @param page
* Which page of items to return
* @return
* A list of {@link SingularityRequestHistory}
*/
public Collection<SingularityRequestHistory> getHistoryForRequest(String requestId,Optional<Integer> count,Optional<Integer> page) {
final String requestUri = String.format(REQUEST_HISTORY_FORMAT,getHost(),contextpath,requestId);
Optional<Map<String,Object>> maybeQueryParams = Optional.<Map<String,Object>>absent();
ImmutableMap.Builder<String,Object> queryParamsBuilder = ImmutableMap.<String,Object>builder();
if (count.isPresent() ) {
queryParamsBuilder.put("count",count.get());
}
if (page.isPresent()) {
queryParamsBuilder.put("page",page.get());
}
Map<String,Object> queryParams = queryParamsBuilder.build();
if (!queryParams.isEmpty()) {
maybeQueryParams = Optional.of(queryParams);
}
return getCollectionWithParams(requestUri,"request history",maybeQueryParams,REQUEST_HISTORY_COLLECTION);
}
项目:Mastering-Mesos
文件:SingularityClient.java
/**
* Retrieve part of the contents of a file in a specific task's sandBox.
*
* @param taskId
* The task ID of the sandBox to read from
* @param path
* The path to the file to be read. Relative to the sandBox root (without a leading slash)
* @param grep
* Optional string to grep for
* @param offset
* Byte offset to start reading from
* @param length
* Maximum number of bytes to read
* @return
* A {@link MesosFileChunkObject} that contains the requested partial file contents
*/
public Optional<MesosFileChunkObject> readSandBoxFile(String taskId,String path,Optional<String> grep,Optional<Long> offset,Optional<Long> length) {
final String requestUrl = String.format(SANDBox_READ_FILE_FORMAT,taskId);
Builder<String,Object> queryParamBuider = ImmutableMap.<String,Object>builder().put("path",path);
if (grep.isPresent()) {
queryParamBuider.put("grep",grep.get());
}
if (offset.isPresent()) {
queryParamBuider.put("offset",offset.get());
}
if (length.isPresent()) {
queryParamBuider.put("length",length.get());
}
return getSingleWithParams(requestUrl,"Read sandBox file for task",taskId,Optional.<Map<String,Object>>of(queryParamBuider.build()),MesosFileChunkObject.class);
}
/**
* Define what each character represents within the block map
* @param representation char to unlocal.getZ()ed block name map
* @exception NullPointerException thrown if block doesn't exist.
*/
public void assignConstructionDef(ImmutableMap<Character,String> representation)
{
Builder<Character,IBlockState> builder = ImmutableMap.builder();
for (final Character c: representation.keySet())
{
final String blockName = representation.get(c);
final Block block = Block.getBlockFromName(blockName);
checkNotNull(block,"assignConstructionDef.Block does not exist " + blockName);
builder.put(c,block.getDefaultState());
}
//default
builder.put(' ',Blocks.AIR.getDefaultState());
conDef = builder.build();
}
private void introspectWebServiceMethod(Builder<WebPath,Handler> builder,String httpMethod,String basePath,Object webService,Method method) {
String path = basePath;
Path methodpath = method.getAnnotation(Path.class);
if (methodpath != null) {
path = Joiner.on("/").join(Arrays.asList(basePath,methodpath.value()));
}
path = CharMatcher.is('/').collapseFrom(path,'/');
WebPath webPath = new WebPath(httpMethod,path);
logger.log(Level.FInesT,format("HTTP {0} {1} -> {2}.{3}",httpMethod,path,webService.getClass().getSimpleName(),method.getName()));
builder.put(webPath,new Handler(webService,method));
}
项目:xtext-extras
文件:JvmTypesResourceDescriptionStrategy.java
protected void createuserData(EObject eObject,ImmutableMap.Builder<String,String> userData) {
if (eObject instanceof JvmDeclaredType) {
userData.put(SIGNATURE_HASH_KEY,hashProvider.getHash((JvmDeclaredType) eObject));
if (eObject.eContainer() != null) {
userData.put(IS_nesTED_TYPE,Boolean.TRUE.toString());
}
}
if (eObject instanceof JvmGenericType) {
JvmGenericType genericType = (JvmGenericType) eObject;
if (genericType.isInterface())
userData.put(IS_INTERFACE,Boolean.TRUE.toString());
if (!genericType.getTypeParameters().isEmpty()) {
String result = "<";
for (Iterator<JvmTypeParameter> iterator = genericType.getTypeParameters().iterator(); iterator.hasNext();) {
JvmTypeParameter type = iterator.next();
result += type.getSimpleName();
if (iterator.hasNext()) {
result += ",";
}
}
result +=">";
userData.put(TYPE_ParaMETERS,result);
}
}
}
项目:TRHS_Club_Mod_2016
文件:LoadController.java
public ImmutableBiMap<ModContainer,new RuntimeException());
}
}
}
return builder.build();
}
项目:DtoTester
文件:DtoTest.java
/**
* Creates an instance of {@link DtoTest} with ignore fields and additional custom mappers.
*
* @param customMappers Any custom mappers for a given class type.
* @param ignoreFields The getters which should be ignored (e.g.,"getId" or "isActive").
*/
protected DtoTest(Map<Class<?>,supplier<?>> customMappers,Set<String> ignoreFields) {
this.ignoredGetFields = new HashSet<>();
if (ignoreFields != null) {
this.ignoredGetFields.addAll(ignoreFields);
}
this.ignoredGetFields.add("getClass");
if (customMappers == null) {
this.mappers = DEFAULT_MAPPERS;
} else {
final Builder<Class<?>,supplier<?>> builder = ImmutableMap.builder();
builder.putAll(customMappers);
builder.putAll(DEFAULT_MAPPERS);
this.mappers = builder.build();
}
}
项目:ColorConsole
文件:CommonFormatter.java
public CommonFormatter(Collection<String> ignoreMessages,boolean colorizeTag,boolean truncateColor,String> levelColors) {
this.ignoreMessages = ImmutableSet.copyOf(ignoreMessages);
this.colorizeTag = colorizeTag;
this.truncateColor = truncateColor;
Builder<String,String> builder = ImmutableMap.builder();
for (Map.Entry<String,String> entry : levelColors.entrySet()) {
if ("INFO".equals(entry.getKey())) {
continue;
}
builder.put(entry.getKey(),format(entry.getValue()));
}
this.levelColors = builder.build();
}
项目:ColorConsole
文件:CommonFormatter.java
public void initPluginColors(Iterable<String> plugins,String> configColors,String def) {
Color[] colors = Color.values();
//remove black,because it's often hard to read
colors = Arrays.copyOfRange(colors,colors.length);
ImmutableMap.Builder<String,String> colorBuilder = ImmutableMap.builder();
for (String plugin : plugins) {
String styleCode = configColors.getorDefault(plugin,def);
if ("random".equalsIgnoreCase(styleCode)) {
//ignore default
styleCode = colors[ThreadLocalRandom.current().nextInt(colors.length - 1)].name();
}
colorBuilder.put(plugin,format(styleCode));
}
this.pluginColors = colorBuilder.build();
}
@Override
Builder<String,pages);
}
return builder;
}
@Override
Builder<String,author);
}
if (hasPages()) {
List<String> pagesstring = new ArrayList<String>();
for (IChatBaseComponent comp : pages) {
pagesstring.add(CraftChatMessage.fromComponent(comp));
}
builder.put(BOOK_PAGES.BUKKIT,pagesstring);
}
if (generation != null) {
builder.put(GENERATION.BUKKIT,generation);
}
return builder;
}
@Override
Builder<String,pages);
}
return builder;
}
项目:guava-libraries
文件:ImmutableMapTest.java
public void testBuilder_withMutableEntry() {
ImmutableMap.Builder<String,1);
}
@Override
Builder<String,pages);
}
return builder;
}
@Override
Builder<String,Object> builder) {
super.serialize(builder);
if (hasColor()) {
builder.put(COLOR.BUKKIT,color);
}
return builder;
}
@Override
Builder<String,Object> builder) {
super.serialize(builder);
if (hasEffect()) {
builder.put(EXPLOSION.BUKKIT,effect);
}
return builder;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。