Example usage for com.google.common.collect Multimap put

List of usage examples for com.google.common.collect Multimap put

Introduction

In this page you can find the example usage for com.google.common.collect Multimap put.

Prototype

boolean put(@Nullable K key, @Nullable V value);

Source Link

Document

Stores a key-value pair in this multimap.

Usage

From source file:com.griddynamics.jagger.engine.e1.collector.BasicSessionCollector.java

@Override
public void onSessionStarted(String sessionId, Multimap<NodeType, NodeId> nodes) {
    taskCounter = 0;/*from  w  w w  .j  a v a  2  s  . c  om*/

    Namespace namespace = Namespace.of(SESSION, sessionId);
    Multimap<String, Object> objectsMap = HashMultimap.create();
    objectsMap.put(START_TIME, System.currentTimeMillis());
    Collection<NodeId> kernels = nodes.get(NodeType.KERNEL);
    objectsMap.put(KERNELS_COUNT, kernels.size());

    for (NodeId nodeId : kernels) {
        objectsMap.put(AVAILABLE_KERNELS, nodeId.toString());
    }
    keyValueStorage.putAll(namespace, objectsMap);
}

From source file:com.griddynamics.jagger.engine.e1.collector.BasicSessionCollector.java

@Override
public void onSessionExecuted(String sessionId, String sessionComment, SessionExecutionStatus status) {
    Namespace namespace = Namespace.of(SESSION, sessionId);
    Multimap<String, Object> objectsMap = HashMultimap.create();
    objectsMap.put(END_TIME, System.currentTimeMillis());
    objectsMap.put(TASK_EXECUTED, taskCounter);
    Integer failedTasks = taskExecutionStatusProvider.getTasksWithStatus(TaskData.ExecutionStatus.FAILED)
            .size();/*from   ww  w  . j ava2  s.co  m*/
    objectsMap.put(FAILED, failedTasks);
    if (failedTasks > 0) {
        if (SessionExecutionStatus.EMPTY.equals(status)) {
            status = SessionExecutionStatus.TASK_FAILED;
        }
    }
    objectsMap.put(ERROR_MESSAGE, status.getMessage());

    keyValueStorage.putAll(namespace, objectsMap);
}

From source file:matteroverdrive.items.android.TritaniumSpine.java

@Override
public Multimap<String, AttributeModifier> getModifiers(AndroidPlayer player, ItemStack itemStack) {
    Multimap multimap = super.getModifiers(player, itemStack);
    if (multimap.isEmpty()) {
        multimap.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(),
                new AttributeModifier(healthModifierID, MOStringHelper.translateToLocal(
                        "attribute.name." + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()),
                        2f, 0));//ww w  .ja v  a 2 s.co  m
        multimap.put(AndroidAttributes.attributeGlitchTime.getAttributeUnlocalizedName(),
                new AttributeModifier(glitchModifierID,
                        MOStringHelper.translateToLocal("attribute.name.android.glitchTime"), -0.5f, 2));
    }
    return multimap;
}

From source file:com.pronoiahealth.olhie.client.widgets.booklist3d.BookListDiv3DEventObserver.java

/**
 * The corresponding request event is fired when the user clicks the book.
 * When this happens a check is done to see if the user clicking the book is
 * the author or co-author of the book. If yes then the user will be
 * navigated to the NewBookPage where they cab edit the contents of the
 * book./*ww  w.ja  v a2  s . c o  m*/
 * 
 * 
 * @param checkBookIsAuthorResponseEvent
 */
protected void observesCheckBookIsAuthorResponseEvent(
        @Observes CheckBookIsAuthorResponseEvent checkBookIsAuthorResponseEvent) {
    boolean isAuthorCoAuthor = checkBookIsAuthorResponseEvent.isAuthorCoAuthor();
    if (isAuthorCoAuthor == true) {
        Multimap<String, String> map = ArrayListMultimap.create();
        map.put("bookId", checkBookIsAuthorResponseEvent.getBookId());
        nav.performTransition(NavEnum.NewBookPage_2.toString(), map);
    }
}

From source file:org.wso2.msf4j.security.JWTSecurityInterceptor.java

public boolean preCall(HttpRequest request, HttpResponder responder, ServiceMethodInfo serviceMethodInfo) {
    HttpHeaders headers = request.headers();
    boolean isValidSignature;
    if (headers != null) {
        String jwtHeader = headers.get(JWT_HEADER);
        if (jwtHeader != null) {
            isValidSignature = verifySignature(jwtHeader);
            if (isValidSignature) {
                return true;
            }/*from  w w  w. j  av  a2 s . c om*/
        }
    }
    Multimap<String, String> map = ArrayListMultimap.create();
    map.put(HttpHeaders.Names.WWW_AUTHENTICATE, AUTH_TYPE_JWT);
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED, map);

    return false;
}

From source file:org.apache.samza.execution.StreamManager.java

public void createStreams(List<StreamSpec> streams) {
    Multimap<String, StreamSpec> streamsGroupedBySystem = HashMultimap.create();
    streams.forEach(streamSpec -> streamsGroupedBySystem.put(streamSpec.getSystemName(), streamSpec));

    for (Map.Entry<String, Collection<StreamSpec>> entry : streamsGroupedBySystem.asMap().entrySet()) {
        String systemName = entry.getKey();
        SystemAdmin systemAdmin = sysAdmins.get(systemName);

        for (StreamSpec stream : entry.getValue()) {
            LOGGER.info("Creating stream {} with partitions {} on system {}",
                    new Object[] { stream.getPhysicalName(), stream.getPartitionCount(), systemName });
            systemAdmin.createStream(stream);
        }/*  www .j a v a  2  s  .c o m*/
    }
}

From source file:bio.gcat.operation.Operation.java

public static Multimap<String, Class<? extends Operation>> getGroups() {
    Multimap<String, Class<? extends Operation>> groups = TreeMultimap.create(Comparator.reverseOrder(),
            new Comparator<Class<? extends Operation>>() {
                @Override//from ww  w.  ja v a 2  s  .  c om
                public int compare(Class<? extends Operation> operationA,
                        Class<? extends Operation> operationB) {
                    Cataloged catalogedA = operationA.getAnnotation(Cataloged.class),
                            catalogedB = operationB.getAnnotation(Cataloged.class);
                    int orderA = catalogedA != null ? catalogedA.order() : Short.MAX_VALUE,
                            orderB = catalogedB != null ? catalogedB.order() : Short.MAX_VALUE;
                    return orderA != orderB ? Integer.compare(orderA, orderB)
                            : operationA.getSimpleName().compareTo(operationB.getSimpleName());
                }
            });
    for (Class<? extends Operation> operation : getOperations(true))
        groups.put(operation.getAnnotation(Cataloged.class).group(), operation);
    return groups;
}

From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java

private static Multimap<String, String> loadGroups(String groupFilePath) throws ManageUsersException {
    Multimap<String, String> groupsMap = TreeMultimap.create();
    String line = null;//w w  w .j  av  a 2s  .c  om

    try (BufferedReader reader = new BufferedReader(
            new InputStreamReader(new FileInputStream(groupFilePath)))) {
        while ((line = reader.readLine()) != null) {
            if (!line.trim().isEmpty()) {
                String[] u2g = line.split(":");
                if (u2g.length == 2) {
                    groupsMap.put(u2g[0].trim(), u2g[1].trim());
                }
            }
        }
    } catch (IOException e) {
        exitWithErrorMessage("could not read group file : " + groupFilePath, null, e);
    }
    return groupsMap;
}

From source file:org.ldp4j.http.ImmutableNegotiationResult.java

private void addContentHeaders(final Multimap<String, String> headers, final Variant variant) {
    headers.put(ContentNegotiation.CONTENT_TYPE, Variants.contentType(variant).toHeader());
    if (variant.language() != null) {
        headers.put(ContentNegotiation.CONTENT_LANGUAGE, variant.language().toHeader());
    }//from   w ww .j  ava  2 s  . co m
}

From source file:org.wso2.carbon.jaas.authinterceptor.BasicAuthInterceptor.java

@Override
public boolean preCall(HttpRequest request, HttpResponder responder, ServiceMethodInfo serviceMethodInfo) {

    HttpHeaders headers = request.headers();
    if (headers != null) {
        String authHeader = headers.get(HttpHeaders.Names.AUTHORIZATION);
        if (authHeader != null) {
            String authType = authHeader.substring(0, AUTH_TYPE_BASIC_LENGTH);
            String authEncoded = authHeader.substring(AUTH_TYPE_BASIC_LENGTH).trim();
            if (AUTH_TYPE_BASIC.equals(authType) && !authEncoded.isEmpty()) {
                byte[] decodedByte = authEncoded.getBytes(Charset.forName("UTF-8"));
                String authDecoded = new String(Base64.getDecoder().decode(decodedByte),
                        Charset.forName("UTF-8"));
                String[] authParts = authDecoded.split(":");

                String username = authParts[0];
                char[] password;
                if (authParts[1] != null && !authParts[1].isEmpty()) {
                    password = authParts[1].toCharArray();
                } else {
                    password = new char[0];
                }//from  w  w w. j a va  2  s.c om

                if (authenticate(username, password)) {
                    return true;
                }
            }
        }
    }
    Multimap<String, String> map = ArrayListMultimap.create();
    map.put(HttpHeaders.Names.WWW_AUTHENTICATE, AUTH_TYPE_BASIC);
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED, map);
    return false;
}