Example usage for com.google.common.collect ImmutableMap of

List of usage examples for com.google.common.collect ImmutableMap of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap of.

Prototype

public static <K, V> ImmutableMap<K, V> of(K k1, V v1) 

Source Link

Usage

From source file:com.opengamma.financial.conversion.CurrencyAmountConverter.java

@Override
public Map<String, Double> convert(String valueName, CurrencyAmount value) {
    return ImmutableMap.of(valueName, value.getAmount());
}

From source file:com.facebook.buck.io.watchman.FakeWatchmanFactory.java

/**
 * Create Watchman instance that can be used in tests
 *
 * @param client client instance used by a test, usually FakeWatchmanClient, can be configured for
 *     specified behavior/*w w  w .  j  a v a 2 s  .c  om*/
 * @param rootPath Absolute path to watchman root folder
 * @param watchPath Path to watch changes for
 * @param projectName Identifier of a watch used to get results from queries
 */
public static Watchman createWatchman(WatchmanClient client, Path rootPath, Path watchPath,
        String projectName) {
    return new Watchman(
            ImmutableMap.of(rootPath, ProjectWatch.of(watchPath.toString(), Optional.of(projectName))),
            ImmutableSet.of(Capability.SUPPORTS_PROJECT_WATCH, Capability.DIRNAME, Capability.WILDMATCH_GLOB),
            ImmutableMap.of(), Optional.of(Paths.get(".watchman-sock"))) {
        @Override
        public WatchmanClient createClient() {
            return client;
        }
    };
}

From source file:com.android.tools.idea.welcome.WelcomeUIUtils.java

private static void makeButtonAHyperlink(JButton button) {
    button.setBorderPainted(false);// w  w  w  .  j a v a  2 s . c  o m
    button.setBorder(null);
    button.setForeground(JBColor.blue);
    button.setOpaque(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFont(button.getFont()
            .deriveFont(ImmutableMap.of(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL)));
}

From source file:io.druid.common.utils.ServletResourceUtils.java

/**
 * Sanitize the exception as a map of "error" to information about the exception.
 *
 * This method explicitly suppresses the stack trace and any other logging. Any logging should be handled by the caller.
 * @param t The exception to sanitize// w  w  w .j a  v a  2  s .  c  o m
 * @return An immutable Map with a single entry which maps "error" to information about the error suitable for passing as an entity in a servlet error response.
 */
public static Map<String, String> sanitizeException(@Nullable Throwable t) {
    return ImmutableMap.of("error",
            t == null ? "null" : (t.getMessage() == null ? t.toString() : t.getMessage()));
}

From source file:com.bjond.utilities.NetworkUtils.java

public static Map<String, String> generateSuccessMap(
        @NotNull(message = "message must not be null.") final String message) {
    return ImmutableMap.of("status", message);
}

From source file:eu.itesla_project.iidm.network.util.Networks.java

public static Map<String, String> getExecutionTags(Network network) {
    return ImmutableMap.of("state", network.getStateManager().getWorkingStateId());
}

From source file:org.rf.ide.core.execution.server.response.StopExecution.java

@Override
public String toMessage() {
    try {/*from   ww  w  .  j av a2s .c o  m*/
        final List<Object> arguments = new ArrayList<>();
        final Map<String, Object> value = ImmutableMap.of("stop", arguments);

        return new ObjectMapper().writeValueAsString(value);
    } catch (final IOException e) {
        throw new ResponseException("Unable to serialize stop response arguments to json", e);
    }
}

From source file:org.rf.ide.core.execution.server.response.StartExecution.java

@Override
public String toMessage() {
    try {/*from   w w w  .j a  v  a2 s  .  com*/
        final List<Object> arguments = new ArrayList<>();
        final Map<String, Object> value = ImmutableMap.of("do_start", arguments);

        return new ObjectMapper().writeValueAsString(value);
    } catch (final IOException e) {
        throw new ResponseException("Unable to serialize do_start response arguments to json", e);
    }
}

From source file:org.rf.ide.core.execution.server.response.ResumeExecution.java

@Override
public String toMessage() {
    try {//from w w w. ja  va2s .c o  m
        final List<Object> arguments = new ArrayList<>();
        final Map<String, Object> value = ImmutableMap.of("resume", arguments);

        return new ObjectMapper().writeValueAsString(value);
    } catch (final IOException e) {
        throw new ResponseException("Unable to serialize resume response arguments to json", e);
    }
}

From source file:com.google.cloud.spanner.TraceUtil.java

static ImmutableMap<String, AttributeValue> getExceptionAnnotations(RuntimeException e) {
    if (e instanceof SpannerException) {
        return ImmutableMap.of("Status",
                AttributeValue.stringAttributeValue(((SpannerException) e).getErrorCode().toString()));
    }//from ww w  . jav  a 2 s  . c om
    return ImmutableMap.of();
}