Java Code Examples for com.google.common.collect.ImmutableMap.Builder#put()

The following examples show how to use com.google.common.collect.ImmutableMap.Builder#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkspaceService.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@GET
@Path("/settings")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Get workspace server configuration values")
@ApiResponses({@ApiResponse(code = 200, message = "The response contains server settings")})
public Map<String, String> getSettings() {
  Builder<String, String> settings = ImmutableMap.builder();

  settings.put(
      Constants.SUPPORTED_RECIPE_TYPES,
      Joiner.on(",").join(workspaceManager.getSupportedRecipes()));
  settings.put(CHE_WORKSPACE_AUTO_START, Boolean.toString(cheWorkspaceAutoStart));

  if (pluginRegistryUrl != null) {
    settings.put("cheWorkspacePluginRegistryUrl", pluginRegistryUrl);
  }

  if (devfileRegistryUrl != null) {
    settings.put("cheWorkspaceDevfileRegistryUrl", devfileRegistryUrl);
  }

  settings.put(CHE_WORKSPACE_PERSIST_VOLUMES_PROPERTY, Boolean.toString(defaultPersistVolumes));

  return settings.build();
}
 
Example 2
Source File: UserAPIController.java    From onboard with Apache License 2.0 6 votes vote down vote up
/**
 * 获取未完成的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();
}
 
Example 3
Source File: FluentBlobsImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public TempBlob ingest(final InputStream in,
                       @Nullable final String contentType,
                       final Iterable<HashAlgorithm> hashing)
{
  Optional<ClientInfo> clientInfo = facet.clientInfo();

  Builder<String, String> tempHeaders = ImmutableMap.builder();
  tempHeaders.put(TEMPORARY_BLOB_HEADER, "");
  tempHeaders.put(REPO_NAME_HEADER, facet.repository().getName());
  tempHeaders.put(BLOB_NAME_HEADER, "temp");
  tempHeaders.put(CREATED_BY_HEADER, clientInfo.map(ClientInfo::getUserid).orElse("system"));
  tempHeaders.put(CREATED_BY_IP_HEADER, clientInfo.map(ClientInfo::getRemoteIP).orElse("system"));
  tempHeaders.put(CONTENT_TYPE_HEADER, ofNullable(contentType).orElse(APPLICATION_OCTET_STREAM));

  MultiHashingInputStream hashingStream = new MultiHashingInputStream(hashing, in);
  Blob blob = facet.stores().blobStore.create(hashingStream, tempHeaders.build());

  return new TempBlob(blob, hashingStream.hashes(), true, facet.stores().blobStore);
}
 
Example 4
Source File: CraftMetaBook.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@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 (ITextComponent comp : pages) {
            pagesString.add(CraftChatMessage.fromComponent(comp));
        }
        builder.put(BOOK_PAGES.BUKKIT, pagesString);
    }

    if (generation != null) {
        builder.put(GENERATION.BUKKIT, generation);
    }

    return builder;
}
 
Example 5
Source File: CraftMetaPotion.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);
    if (type.getType() != PotionType.UNCRAFTABLE) {
        builder.put(DEFAULT_POTION.BUKKIT, CraftPotionUtil.fromBukkit(type));
    } else if (this.emptyType != null) {
        builder.put(DEFAULT_POTION.BUKKIT + "-empty", emptyType);
    }

    if (hasColor()) {
        builder.put(POTION_COLOR.BUKKIT, getColor());
    }

    if (hasCustomEffects()) {
        builder.put(POTION_EFFECTS.BUKKIT, ImmutableList.copyOf(this.customEffects));
    }

    return builder;
}
 
Example 6
Source File: MongoDocumentHistory.java    From baleen with Apache License 2.0 6 votes vote down vote up
private Map<String, String> convertToStringMap(Object object) {
  if (object == null || !(object instanceof Document)) {
    return ImmutableMap.of();
  }
  Document dbo = (Document) object;

  Builder<String, String> builder = ImmutableMap.builder();
  for (Entry<String, Object> e : dbo.entrySet()) {
    if (e.getValue() instanceof String) {
      builder.put(e.getKey(), (String) e.getValue());
    } else {
      builder.put(e.getKey(), e.getValue().toString());
    }
  }

  return builder.build();
}
 
Example 7
Source File: MetaContainer.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
/**
 * Sets non-transitive key fields to this meta container
 * @param keyFields set of key fields
 * @return instance on which it was called on
 */
public MetaContainer setKeyFields(Set<String> keyFields) {
    if (keyFields != null) {
        Builder<String, Boolean> builder = ImmutableMap.builder();

        for (String keyField : keyFields) {
            builder.put(keyField, Boolean.FALSE);
        }

        this.keyFields = builder.build();
    }

    return this;
}
 
Example 8
Source File: MaterialCockpitRowFactory.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@VisibleForTesting
Map<MainRowBucketId, MainRowWithSubRows> createEmptyRowBuckets(
		@NonNull final ImmutableSet<ProductId> productIds,
		@NonNull final LocalDate timestamp,
		final boolean includePerPlantDetailRows)
{
	final DimensionSpec dimensionSpec = MaterialCockpitUtil.retrieveDimensionSpec();

	final List<DimensionSpecGroup> groups = dimensionSpec.retrieveGroups();
	final List<I_S_Resource> plants = retrieveCountingPlants(includePerPlantDetailRows);

	final Builder<MainRowBucketId, MainRowWithSubRows> result = ImmutableMap.builder();
	for (final ProductId productId : productIds)
	{
		final MainRowBucketId key = MainRowBucketId.createPlainInstance(productId, timestamp);
		final MainRowWithSubRows mainRowBucket = MainRowWithSubRows.create(key);

		for (final I_S_Resource plant : plants)
		{
			mainRowBucket.addEmptyCountingSubrowBucket(plant.getS_Resource_ID());
		}

		for (final DimensionSpecGroup group : groups)
		{
			mainRowBucket.addEmptyAttributesSubrowBucket(group);
		}
		result.put(key, mainRowBucket);

	}
	return result.build();
}
 
Example 9
Source File: IYAppearance.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Convert this IYAppearance to an OutputElementStyle
 *
 * @return The OutputElementStyle from this style
 * @since 6.0
 */
default OutputElementStyle toOutputElementStyle() {
    Builder<String, Object> builder = ImmutableMap.builder();
    builder.put(StyleProperties.STYLE_NAME, getName());
    builder.put(StyleProperties.SERIES_TYPE, getType());
    builder.put(StyleProperties.SERIES_STYLE, getStyle());
    builder.put(StyleProperties.COLOR, getColor());
    builder.put(StyleProperties.WIDTH, getWidth());
    builder.put(StyleProperties.SYMBOL_TYPE, getSymbolStyle());
    builder.put(StyleProperties.HEIGHT, getSymbolSize());
    return new OutputElementStyle(null, builder.build());
}
 
Example 10
Source File: CraftMetaSkull.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);
    if (hasOwner()) {
        return builder.put(SKULL_OWNER.BUKKIT, this.profile.getName());
    }
    return builder;
}
 
Example 11
Source File: TypeManagerTest.java    From binnavi with Apache License 2.0 5 votes vote down vote up
private ImmutableMap<TypeMember, Integer> captureMemberOffsets() {
  final Builder<TypeMember, Integer> builder = ImmutableMap.<TypeMember, Integer>builder();
  for (BaseType baseType : typeSystem.getTypes()) {
    for (TypeMember member : baseType) {
      if (member.getBitOffset().isPresent()) {
        builder.put(member, member.getBitOffset().get());
      }
    }
  }
  return builder.build();
}
 
Example 12
Source File: UserAPIController.java    From onboard with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/{companyId}/user/{userId}/activities", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class, UserChecking.class })
@ResponseBody
public Map<String, Object> viewUserActivities(@PathVariable int companyId, @PathVariable int userId,
        @RequestParam(value = "until", required = false) @DateTimeFormat(iso = ISO.DATE) Date until, Model model) {

    Builder<String, Object> builder = ImmutableMap.builder();

    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    List<Integer> projectList = getProjectListOfCurrentUser(companyId);
    TreeMap<Date, List<Activity>> map = activityService.getByUserGroupByDate(companyId, userId, ACTIVITY_PER_PAGE,
            projectList, until);

    TreeMap<String, List<ActivityDTO>> mapDTO = makeMapSerilizable(map);
    builder.put("activities", mapDTO);
    boolean hasNext = false;

    if (map != null && map.size() > 0) {
        Date newUntil = new DateTime(map.lastKey()).plusDays(-1).withTime(0, 0, 0, 0).toDate();
        TreeMap<Date, List<Activity>> nextMap = activityService.getByUserGroupByDate(companyId, userId,
                ACTIVITY_PER_PAGE, projectList, newUntil);
        hasNext = nextMap != null;
        builder.put("nextPage", dtf.print(new DateTime(newUntil)));
    }
    builder.put("hasNext", hasNext);

    return builder.build();
}
 
Example 13
Source File: CraftMetaPotion.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasCustomEffects()) {
        builder.put(POTION_EFFECTS.BUKKIT, ImmutableList.copyOf(this.customEffects));
    }

    return builder;
}
 
Example 14
Source File: XYPresentationProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private OutputElementStyle createAppearance(Long seriesId, String seriesType, int width) {
    RGBAColor color = generateColor();
    Builder<String, Object> builder = ImmutableMap.builder();
    builder.put(StyleProperties.STYLE_NAME, seriesId);
    builder.put(StyleProperties.SERIES_TYPE, seriesType);
    builder.put(StyleProperties.SERIES_STYLE, generateStyle(seriesType));
    builder.put(StyleProperties.COLOR, X11ColorUtils.toHexColor(color.getRed(), color.getGreen(), color.getBlue()));
    builder.put(StyleProperties.WIDTH, width);
    return new OutputElementStyle(null, builder.build());
}
 
Example 15
Source File: QuotaQueryConverter.java    From james-project with Apache License 2.0 5 votes vote down vote up
QuotaQueryConverter() {
    Builder<Class<? extends QuotaClause>, Function<QuotaClause, QueryBuilder>> builder = ImmutableMap.builder();
    
    builder.put(HasDomain.class, this::convertHasDomain);
    builder.put(And.class, this::disableNestedAnd);
    builder.put(MoreThan.class, this::convertMoreThan);
    builder.put(LessThan.class, this::convertLessThan);

    clauseConverter = builder.build();
}
 
Example 16
Source File: CraftMetaFirework.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasEffects()) {
        builder.put(EXPLOSIONS.BUKKIT, ImmutableList.copyOf(effects));
    }

    if (hasPower()) {
        builder.put(FLIGHT.BUKKIT, power);
    }

    return builder;
}
 
Example 17
Source File: CraftMetaKnowledgeBook.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasRecipes()) {
        List<String> recipesString = new ArrayList<String>();
        for (NamespacedKey recipe : recipes) {
            recipesString.add(recipe.toString());
        }
        builder.put(BOOK_RECIPES.BUKKIT, recipesString);
    }

    return builder;
}
 
Example 18
Source File: CraftMetaLeatherArmor.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

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

    return builder;
}
 
Example 19
Source File: EntityQueryNode.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs an instance of {@link EntityQueryNode}.
 *
 * @param type - The type of {@link Entity} this node matches. (not null)
 * @param patterns - The query StatementPatterns that are solved using an
 *   Entity of the Type. (not null)
 * @param entities - The {@link EntityStorage} that will be searched to match
 *   {@link BindingSet}s when evaluating a query. (not null)
 */
public EntityQueryNode(final Type type, final Collection<StatementPattern> patterns, final EntityStorage entities) throws IllegalStateException {
    this.type = requireNonNull(type);
    this.patterns = requireNonNull(patterns);
    this.entities = requireNonNull(entities);

    bindingNames = new HashSet<>();
    properties = new HashSet<>();
    // Subject based preconditions.
    verifySameSubjects(patterns);

    // Predicate based preconditions.
    verifyAllPredicatesAreConstants(patterns);
    verifyHasCorrectTypePattern(type, patterns);
    verifyAllPredicatesPartOfType(type, patterns);

    // The Subject may either be constant or a variable.
    final Var subject = patterns.iterator().next().getSubjectVar();
    subjectIsConstant = subject.isConstant();
    if(subjectIsConstant) {
        subjectConstant = Optional.of( subject.getValue().toString() );
        subjectVar = Optional.empty();
    } else {
        subjectConstant = Optional.empty();
        subjectVar = Optional.of( subject.getName() );
    }

    // Any constant that appears in the Object portion of the SP will be used to make sure they match.
    final Builder<RyaIRI, Var> builder = ImmutableMap.builder();
    for(final StatementPattern sp : patterns) {
        final Var object = sp.getObjectVar();
        final Var pred = sp.getPredicateVar();
        final RyaIRI predIRI = new RyaIRI(pred.getValue().stringValue());
        bindingNames.addAll(sp.getBindingNames());
        if(object.isConstant() && !pred.getValue().equals(RDF.TYPE)) {
            final RyaType propertyType = RdfToRyaConversions.convertValue(object.getValue());
            properties.add(new Property(predIRI, propertyType));
        }
        builder.put(predIRI, object);
    }
    objectVariables = builder.build();
}
 
Example 20
Source File: PairingStateMachine.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
private static void add(Builder<String, PairingState> builder, PairingState state) {
	builder.put(state.name(), state);
}