Java 类com.google.common.collect.ImmutableMap.Builder 实例源码

项目: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();
}
项目:CauldronGit    文件:CraftMetaBook.java   
@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);
}
项目:n4js    文件:WorkingSetManagerBrokerImpl.java   
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();
        });
    }
项目:Uranium    文件:CraftMetaBook.java   
@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-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(), "one", 1);
}
项目:guava-mock    文件: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);
}
项目: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, Map<String, 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(), seenPlugins, 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();
}
项目:googles-monorepo-demo    文件: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(), "one", 1);
}
项目:googles-monorepo-demo    文件: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);
}
项目:CustomWorldGen    文件:LoadController.java   
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();
}
项目:hashsdn-controller    文件:DOMRpcRoutingTable.java   
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);
}
项目:hashsdn-controller    文件:AbstractDOMRpcRoutingTableEntry.java   
/**
 *
 * @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());
}
项目:hashsdn-controller    文件:AbstractDOMRpcRoutingTableEntry.java   
final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation,
        final List<YangInstanceIdentifier> removed) {
    final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
    for (final Entry<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);
}
项目:hashsdn-controller    文件:MetadataShardDataTreeSnapshot.java   
@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, Map<String, 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, getHost(), contextPath, 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);
}
项目:Structure    文件:StructureDefinitionBuilder.java   
/**
 * 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();
}
项目:greenbeans    文件:WebDispatch.java   
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, 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();
}
项目: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
        , Map<String, 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, Map<String, String> configColors, String def) {
    Color[] colors = Color.values();
    //remove black, because it's often hard to read
    colors = Arrays.copyOfRange(colors, 1, 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();
}
项目:ThermosRebased    文件:CraftMetaBook.java   
@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;
}
项目:Craftbukkit    文件:CraftMetaBook.java   
@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()) {
        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;
}
项目:KCauldron    文件:CraftMetaBook.java   
@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 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);
}
项目:guava-libraries    文件: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(), "one", 1);
}
项目:FFoKC    文件:CraftMetaBook.java   
@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;
}
项目:Uranium    文件:CraftMetaLeatherArmor.java   
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasColor()) {
        builder.put(COLOR.BUKKIT, color);
    }

    return builder;
}
项目:Uranium    文件:CraftMetaCharge.java   
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasEffect()) {
        builder.put(EXPLOSION.BUKKIT, effect);
    }

    return builder;
}