com.google.common.collect.Maps#transformValues ( )源码实例Demo

下面列出了com.google.common.collect.Maps#transformValues ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Strata   文件: ExampleMarketDataBuilder.java
/**
 * Gets all rates curves.
 * 
 * @return the map of all rates curves
 */
public SortedMap<LocalDate, RatesCurveGroup> loadAllRatesCurves() {
  if (!subdirectoryExists(CURVES_DIR)) {
    throw new IllegalArgumentException("No rates curves directory found");
  }
  ResourceLocator curveGroupsResource = getResource(CURVES_DIR, CURVES_GROUPS_FILE);
  if (curveGroupsResource == null) {
    throw new IllegalArgumentException(Messages.format(
        "Unable to load rates curves: curve groups file not found at {}/{}", CURVES_DIR, CURVES_GROUPS_FILE));
  }
  ResourceLocator curveSettingsResource = getResource(CURVES_DIR, CURVES_SETTINGS_FILE);
  if (curveSettingsResource == null) {
    throw new IllegalArgumentException(Messages.format(
        "Unable to load rates curves: curve settings file not found at {}/{}", CURVES_DIR, CURVES_SETTINGS_FILE));
  }
  ListMultimap<LocalDate, RatesCurveGroup> curveGroups =
      RatesCurvesCsvLoader.loadAllDates(curveGroupsResource, curveSettingsResource, getRatesCurvesResources());

  // There is only one curve group in the market data file so this will always succeed
  Map<LocalDate, RatesCurveGroup> curveGroupMap = Maps.transformValues(curveGroups.asMap(), groups -> groups.iterator().next());
  return new TreeMap<>(curveGroupMap);
}
 
源代码2 项目: OpenModsLib   文件: ItemStateModel.java
@Override
public IBakedModel bake(IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel defaultModel;

	if (this.defaultModel.isPresent()) {
		defaultModel = getModel(this.defaultModel.get());
	} else if (!this.stateModels.isEmpty()) {
		final ResourceLocation first = this.stateModels.values().iterator().next();
		defaultModel = getModel(first);
	} else {
		defaultModel = ModelLoaderRegistry.getMissingModel();
	}

	final IBakedModel bakedDefaultModel = defaultModel.bake(defaultModel.getDefaultState(), format, bakedTextureGetter);

	final Map<State, IBakedModel> bakedStateModels = Maps.transformValues(stateModels, input -> {
		final IModel model = getModel(input);
		return model.bake(model.getDefaultState(), format, bakedTextureGetter);
	});

	return new ItemStateOverrideList(bakedStateModels).wrapModel(bakedDefaultModel);
}
 
源代码3 项目: atlas   文件: AtlasJanusGraph.java
private Object convertGremlinValue(Object rawValue) {
    if (rawValue instanceof Vertex) {
        return GraphDbObjectFactory.createVertex(this, (Vertex) rawValue);
    } else if (rawValue instanceof Edge) {
        return GraphDbObjectFactory.createEdge(this, (Edge) rawValue);
    } else if (rawValue instanceof Map) {
        Map<String, Object> rowValue = (Map<String, Object>) rawValue;

        return Maps.transformValues(rowValue, GREMLIN_VALUE_CONVERSION_FUNCTION);
    } else if (rawValue instanceof ImmutablePath) {
        ImmutablePath path = (ImmutablePath) rawValue;

        return convertGremlinValue(path.objects());
    } else if (rawValue instanceof List) {
        return Lists.transform((List) rawValue, GREMLIN_VALUE_CONVERSION_FUNCTION);
    } else if (rawValue instanceof Collection) {
        throw new UnsupportedOperationException("Unhandled collection type: " + rawValue.getClass());
    }

    return rawValue;
}
 
源代码4 项目: phoenix   文件: PhoenixRuntime.java
private static Map<String, Map<String, Long>> transformMetrics(Map<String, Map<MetricType, Long>> metricMap) {
	Function<Map<MetricType, Long>, Map<String, Long>> func = new Function<Map<MetricType, Long>, Map<String, Long>>() {
		@Override
		public Map<String, Long> apply(Map<MetricType, Long> map) {
			return createMetricMap(map);
		}
	};
	return Maps.transformValues(metricMap, func);
}
 
源代码5 项目: drift   文件: ArrayField.java
public Map<Short, List<Long>> getMapLongList()
{
    if (mapLongArray == null) {
        return null;
    }
    return Maps.transformValues(this.mapLongArray, Longs::asList);
}
 
源代码6 项目: selenium   文件: JsonToWebElementConverter.java
@Override
public Object apply(Object result) {
  if (result instanceof Collection<?>) {
    Collection<?> results = (Collection<?>) result;
    return Lists.newArrayList(Iterables.transform(results, this));
  }

  if (result instanceof Map<?, ?>) {
    Map<?, ?> resultAsMap = (Map<?, ?>) result;
    String elementKey = getElementKey(resultAsMap);
  if (null != elementKey) {
	  RemoteWebElement element = newRemoteWebElement();
	  element.setId(String.valueOf(resultAsMap.get(elementKey)));
	  return element;
    } else {
      return Maps.transformValues(resultAsMap, this);
    }
  }

  if (result instanceof RemoteWebElement) {
    return setOwner((RemoteWebElement) result);
  }

  if (result instanceof Number) {
    if (result instanceof Float || result instanceof Double) {
      return ((Number) result).doubleValue();
    }
    return ((Number) result).longValue();
  }

  return result;
}
 
public final List<TokenNameBinding> getNameBindings(final ASTNode node,
		final File file) throws IOException {
	final Set<Set<ASTNode>> nodeBindings = getNameBindings(node);
	final SortedMap<Integer, String> tokenPositions = Maps.transformValues(
			tokenizer.tokenListWithPos(file),
			FullToken.TOKEN_NAME_CONVERTER);
	return getTokenBindings(tokenPositions, nodeBindings);
}
 
源代码8 项目: DCMonitor   文件: JsonValues.java
public static <T> JsonValues of(Map<String, T> rawValues) {
  return new JsonValues(
    Maps.transformValues(
      rawValues, new Function<T, Object>() {
        @Override
        public Object apply(T input) {
          return (Object) input;
        }
      }
    )
  );
}
 
源代码9 项目: drift   文件: ArrayField.java
public Map<Short, List<Boolean>> getMapBooleanList()
{
    if (mapBooleanArray == null) {
        return null;
    }
    return Maps.transformValues(mapBooleanArray, Booleans::asList);
}
 
源代码10 项目: digdag   文件: RedshiftConnectionConfigTest.java
@Before
public void setUp()
        throws IOException
{
    {
        // This map contains only minimum custom values to test default values
        Map<String, String> defaultConfigValues = ImmutableMap.of(
                "host", "foobar0.org",
                "user", "user0",
                "database", "database0"
        );

        this.connConfigWithDefaultValue = RedshiftConnectionConfig.configure(
                key -> Optional.absent(), jdbcOpTestHelper.createConfig(defaultConfigValues)
        );

        // This map contains values that are all "ignore" so that we can detect if this value is used unexpectedly
        Map<String, String> ignoredDefaultConfigValues = Maps.transformValues(defaultConfigValues, key -> "ignore");

        this.connConfigWithDefaultValueFromSecrets = RedshiftConnectionConfig.configure(
                key -> Optional.fromNullable(defaultConfigValues.get(key)), jdbcOpTestHelper.createConfig(ignoredDefaultConfigValues)
        );
    }

    // This map contains whole custom values to test if custom values are used expectedly
    Map<String, String> customConfigValues = ImmutableMap.<String, String>builder().
            put("host", "foobar1.org").
            put("port", "6543").
            put("user", "user1").
            put("password", "password1").
            put("database", "database1").
            put("ssl", "true").
            put("connect_timeout", "15s").
            put("socket_timeout", "12 m").
            put("schema", "myschema").build();

    {
        this.connConfigWithCustomValue = RedshiftConnectionConfig.configure(
                key -> key.equals("password") ? Optional.of("password1") : Optional.absent(), jdbcOpTestHelper.createConfig(customConfigValues)
        );

        // This map contains values that are all "ignore" so that we can detect if this value is used unexpectedly
        ImmutableList<String> itemsFromOnlyConfig = ImmutableList.of("connect_timeout", "socket_timeout");
        Map<String, String> ignoredCustomConfigValues =
                Maps.transformEntries(customConfigValues,
                        (key, value) -> itemsFromOnlyConfig.contains(key) ? value : "ignore");

        this.connConfigWithCustomValueFromSecrets = RedshiftConnectionConfig.configure(
                key -> Optional.fromNullable(customConfigValues.get(key)), jdbcOpTestHelper.createConfig(ignoredCustomConfigValues)
        );
    }

    {
        Map<String, String> configValuesWithOverriddenPassword = ImmutableMap.<String, String>builder()
                .putAll(customConfigValues)
                .put("another_db_password", "password2")
                .build();

        Map<String, String> configValuesUsingOverriddenPassword = ImmutableMap.<String, String>builder()
                .putAll(customConfigValues)
                .put("password_override", "another_db_password")
                .build();

        this.connConfigWithOverriddenPassword = RedshiftConnectionConfig.configure(
                key -> Optional.fromNullable(configValuesWithOverriddenPassword.get(key)),
                jdbcOpTestHelper.createConfig(configValuesUsingOverriddenPassword)
        );
    }
}
 
源代码11 项目: digdag   文件: PgConnectionConfigTest.java
@Before
public void setUp()
        throws IOException
{
    // This map contains only minimum custom values to test default values
    Map<String, String> defaultConfigValues = ImmutableMap.of(
            "host", "foobar0.org",
            "user", "user0",
            "database", "database0"
    );

    this.connConfigWithDefaultValue = PgConnectionConfig.configure(
            key -> Optional.absent(), jdbcOpTestHelper.createConfig(defaultConfigValues)
    );

    // This map contains values that are all "ignore" so that we can detect if this value is used unexpectedly
    Map<String, String> ignoredDefaultConfigValues = Maps.transformValues(defaultConfigValues, key -> "ignore");

    this.connConfigWithDefaultValueFromSecrets = PgConnectionConfig.configure(
            key -> Optional.fromNullable(defaultConfigValues.get(key)), jdbcOpTestHelper.createConfig(ignoredDefaultConfigValues)
    );

    // This map contains whole custom values to test if custom values are used expectedly
    Map<String, String> customConfigValues = ImmutableMap.<String, String>builder().
            put("host", "foobar1.org").
            put("port", "6543").
            put("user", "user1").
            put("password", "password1").
            put("database", "database1").
            put("ssl", "true").
            put("connect_timeout", "15s").
            put("socket_timeout", "12 m").
            put("schema", "myschema").build();

    this.connConfigWithCustomValue = PgConnectionConfig.configure(
            key -> key.equals("password") ? Optional.of("password1") : Optional.absent(), jdbcOpTestHelper.createConfig(customConfigValues)
    );

    // This map contains values that are all "ignore" so that we can detect if this value is used unexpectedly
    Map<String, String> ignoredCustomConfigValues = Maps.transformValues(customConfigValues, key -> "ignore");

    this.connConfigWithCustomValueFromSecrets = PgConnectionConfig.configure(
            key -> Optional.fromNullable(customConfigValues.get(key)), jdbcOpTestHelper.createConfig(ignoredCustomConfigValues)
    );

    Map<String, String> configValuesWithOverriddenPassword = ImmutableMap.<String, String>builder()
            .putAll(customConfigValues)
            .put("another_db_password", "password2")
            .build();

    Map<String, String> configValuesUsingOverriddenPassword = ImmutableMap.<String, String>builder()
            .putAll(customConfigValues)
            .put("password_override", "another_db_password")
            .build();

    this.connConfigWithOverriddenPassword = PgConnectionConfig.configure(
            key -> Optional.fromNullable(configValuesWithOverriddenPassword.get(key)),
            jdbcOpTestHelper.createConfig(configValuesUsingOverriddenPassword)
    );
}
 
源代码12 项目: jpmml-evaluator   文件: KeyValueAggregator.java
protected Map<K, Value<V>> asTransformedMap(Function<Vector<V>, Value<V>> function){
	return Maps.transformValues(this.map, function);
}
 
protected Map<?, ?> transformSpecialFlags(Map<?, ?> flag) {
    return Maps.transformValues(flag, this);
}
 
源代码14 项目: tassal   文件: JavaTypeTokenizer.java
@Override
public SortedMap<Integer, String> tokenListWithPos(final char[] code) {
	return Maps.transformValues(fullTokenListWithPos(code),
			FullToken.TOKEN_NAME_CONVERTER);
}
 
源代码15 项目: yangtools   文件: ModuleNamespaceContext.java
Map<String, String> prefixesAndNamespaces() {
    return Maps.transformValues(prefixToModule, module -> module.localQNameModule().getNamespace().toString());
}
 
源代码16 项目: arctic-sea   文件: Producers.java
public static <K, T> Map<K, T> produce(Map<K, Producer<T>> map) {
    return Maps.transformValues(map, Producer::get);
}
 
源代码17 项目: titan1withtp3.1   文件: FulgoraVertexMemory.java
public Map<Long,EntryList> retrievePartitionAggregates() {
    for (PartitionVertexAggregate agg : partitionVertices.values()) agg.completeIteration();
    return Maps.transformValues(partitionVertices, s -> s.getLoadedProperties());
}
 
源代码18 项目: SpinalTap   文件: MysqlUpdateMutation.java
@VisibleForTesting
static Map<String, Serializable> asColumnValues(@NonNull final Row row) {
  return Maps.transformValues(row.getColumns(), Column::getValue);
}
 
源代码19 项目: n4js   文件: ValueWrappingMap.java
@Override
public void putAll(Map<? extends K, ? extends V> map) {
	super.putAll(Maps.transformValues(map, (v) -> wrapper.apply(v)));
}
 
源代码20 项目: curator-extensions   文件: NodeDiscovery.java
/**
 * Retrieve the available nodes.
 *
 * @return The available nodes.
 */
public Map<String, T> getNodes() {
    return Maps.transformValues(Collections.unmodifiableMap(_nodes), input -> (input != null) ? input.orElse(null) : null);
}