Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

In this page you can find the example usage for java.util LinkedHashMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:javaslang.jackson.datatype.serialize.MapSerializer.java

@Override
Object toJavaObj(Map<?, ?> value) throws IOException {
    final LinkedHashMap<Object, Object> result = new LinkedHashMap<>();
    value.forEach(e -> result.put(e._1, e._2));
    return result;
}

From source file:org.kitodo.data.index.elasticsearch.type.HistoryType.java

@SuppressWarnings("unchecked")
@Override//from  w ww .j  a  v a  2s .  c  o m
public HttpEntity createDocument(History history) {

    LinkedHashMap<String, String> orderedHistoryMap = new LinkedHashMap<>();
    orderedHistoryMap.put("numericValue", history.getNumericValue().toString());
    orderedHistoryMap.put("stringValue", history.getStringValue());
    orderedHistoryMap.put("type", history.getHistoryType().toString());
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = history.getDate() != null ? dateFormat.format(history.getDate()) : null;
    orderedHistoryMap.put("date", date);
    orderedHistoryMap.put("process", history.getProcess().getId().toString());

    JSONObject historyObject = new JSONObject(orderedHistoryMap);

    return new NStringEntity(historyObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.sillelien.dollar.api.types.DollarFactory.java

@NotNull
private static var fromJson(@NotNull JsonObject jsonObject) {
    final Type type;
    if (!jsonObject.containsField(TYPE_KEY)) {
        type = Type.MAP;//from   w w w  . j  ava  2s.  co m
    } else {
        type = Type.valueOf(jsonObject.getString(TYPE_KEY));
    }

    if (type.equals(Type.VOID)) {
        return $void();
    } else if (type.equals(Type.INTEGER)) {
        return fromValue(jsonObject.getLong(VALUE_KEY));
    } else if (type.equals(Type.BOOLEAN)) {
        return fromValue(jsonObject.getBoolean(VALUE_KEY));
    } else if (type.equals(Type.DATE)) {
        return wrap(new DollarDate(ImmutableList.of(), Instant.parse(jsonObject.getString(TEXT_KEY))));
    } else if (type.equals(Type.DECIMAL)) {
        return fromValue(jsonObject.getNumber(VALUE_KEY));
    } else if (type.equals(Type.LIST)) {
        final JsonArray array = jsonObject.getArray(VALUE_KEY);
        ArrayList<Object> arrayList = new ArrayList<>();
        for (Object o : array) {
            arrayList.add(fromJson(o));
        }
        return wrap(new DollarList(ImmutableList.of(), ImmutableList.copyOf(arrayList)));
    } else if (type.equals(Type.MAP)) {
        final JsonObject json;
        json = jsonObject;
        LinkedHashMap<String, Object> map = new LinkedHashMap<>();
        final Set<String> fieldNames = json.getFieldNames();
        for (String fieldName : fieldNames) {
            if (!fieldName.equals(TYPE_KEY)) {
                map.put(fieldName, fromJson(json.get(fieldName)));
            }
        }
        return wrap(new DollarMap(ImmutableList.of(), map));
    } else if (type.equals(Type.ERROR)) {
        final String errorType = jsonObject.getString("errorType");
        final String errorMessage = jsonObject.getString("errorMessage");
        return wrap(new DollarError(ImmutableList.<Throwable>of(), ErrorType.valueOf(errorType), errorMessage));
    } else if (type.equals(Type.RANGE)) {
        final var lower = fromJson(jsonObject.get(LOWERBOUND_KEY));
        final var upper = fromJson(jsonObject.get(UPPERBOUND_KEY));
        return wrap(new DollarRange(ImmutableList.of(), lower, upper));
    } else if (type.equals(Type.URI)) {
        return wrap(new DollarURI(ImmutableList.of(), URI.parse(jsonObject.getString(VALUE_KEY))));
    } else if (type.equals(Type.INFINITY)) {
        return wrap(new DollarInfinity(ImmutableList.of(), jsonObject.getBoolean(POSITIVE_KEY)));
    } else if (type.equals(Type.STRING)) {
        if (!(jsonObject.get(VALUE_KEY) instanceof String)) {
            System.out.println(jsonObject.get(VALUE_KEY));
        }
        return wrap(new DollarString(ImmutableList.of(), jsonObject.getString(VALUE_KEY)));
    } else {
        throw new DollarException("Unrecognized type " + type);
    }
}

From source file:org.terasoluna.gfw.functionaltest.domain.service.sequencer.SequencerServiceImpl.java

@SuppressWarnings("unchecked")
private <T, E> void setSequencerValuesOutput(Sequencer<T> sequencer, LinkedHashMap<String, E> output) {
    output.put("next_value1", (E) sequencer.getNext());
    output.put("current_value1", (E) sequencer.getCurrent());
    output.put("current_value2", (E) sequencer.getCurrent());
    output.put("next_value2", (E) sequencer.getNext());
    output.put("next_value3", (E) sequencer.getNext());
    output.put("current_value3", (E) sequencer.getCurrent());
    output.put("next_value4", (E) sequencer.getNext());
    output.put("current_value4", (E) sequencer.getCurrent());
}

From source file:com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.java

/**
 * trans cube//  w w  w.j  a v  a 2  s  .  c o m
 * @param cube
 * @return new Cube
 */
public static Cube transformCube(Cube cube) {
    MiniCube newCube = (MiniCube) DeepcopyUtils.deepCopy(cube);
    final Map<String, Measure> measures = Maps.newConcurrentMap();
    cube.getMeasures().values().forEach(m -> {
        measures.put(m.getName(), m);
    });
    newCube.setMeasures(measures);
    final Map<String, Dimension> dimensions = Maps.newLinkedHashMap();
    cube.getDimensions().values().forEach(dim -> {
        MiniCubeDimension tmp = (MiniCubeDimension) DeepcopyUtils.deepCopy(dim);
        LinkedHashMap<String, Level> tmpLevel = Maps.newLinkedHashMap();
        dim.getLevels().values().forEach(level -> {
            level.setDimension(dim);
            tmpLevel.put(level.getName(), level);
        });
        tmp.setLevels(tmpLevel);
        dimensions.put(tmp.getName(), tmp);
    });
    newCube.setDimensions(dimensions);
    return newCube;
}

From source file:org.kitodo.data.index.elasticsearch.type.BatchType.java

@SuppressWarnings("unchecked")
@Override//from   ww w .ja v  a  2s  .  c  o  m
public HttpEntity createDocument(Batch batch) {

    LinkedHashMap<String, String> orderedBatchMap = new LinkedHashMap<>();
    orderedBatchMap.put("title", batch.getTitle());
    String type = batch.getType() != null ? batch.getType().toString() : "null";
    orderedBatchMap.put("type", type);

    JSONArray processes = new JSONArray();
    List<Process> batchProcesses = batch.getProcesses();
    for (Process process : batchProcesses) {
        JSONObject processObject = new JSONObject();
        processObject.put("id", process.getId().toString());
        processes.add(processObject);
    }

    JSONObject batchObject = new JSONObject(orderedBatchMap);
    batchObject.put("processes", processes);

    return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.k42b3.quantum.worker.TwitterWorker.java

@Override
public Map<String, String> getParameters() {
    LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("consumer_key", "Consumer key");
    parameters.put("consumer_secret", "Consumer secret");
    parameters.put("token", "Token");
    parameters.put("token_secret", "Token secret");

    return parameters;
}

From source file:org.kitodo.data.index.elasticsearch.type.UserGroupType.java

@SuppressWarnings("unchecked")
@Override//from   w  ww  . j a va  2s.  co m
public HttpEntity createDocument(UserGroup userGroup) {

    LinkedHashMap<String, String> orderedUserGroupMap = new LinkedHashMap<>();
    orderedUserGroupMap.put("title", userGroup.getTitle());
    orderedUserGroupMap.put("permission", userGroup.getPermission().toString());

    JSONArray users = new JSONArray();
    List<User> userGroupUsers = userGroup.getUsers();
    for (User user : userGroupUsers) {
        JSONObject userObject = new JSONObject();
        userObject.put("id", user.getId().toString());
        users.add(userObject);
    }

    JSONObject userGroupObject = new JSONObject(orderedUserGroupMap);
    userGroupObject.put("users", users);

    return new NStringEntity(userGroupObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:citation_prediction.CitationCore.java

/**
 * This function runs the Newton-Raphson function on an interval from .1 to 10 returning a list of
 * all the unique solutions.//  ww w. j a  v a2  s  .co  m
 * 
 * @param data The citation data in days.
 * @param step The step you would like to use to step through the interval of .1 to 10.
 * @param m The average number of new references contained in each paper for a journal.
 * @return A list of list containing the WSB solutions.
 */
private static ArrayList<LinkedHashMap<String, Double>> newtonRaphson_ConvergenceTest(double[][] data,
        double start, double mu_guess, double sigma_guess, double step, double m, boolean wasAlreadyRun) {

    CitationCore cc = new CitationCore();

    String[] matrix_headers = { "mu0", "sigma0", "lambda", "mu", "sigma", "iteration" };
    ArrayList<ArrayList<Double>> matrix = new ArrayList<ArrayList<Double>>(100);
    ArrayList<LinkedHashMap<String, Double>> solutions = new ArrayList<LinkedHashMap<String, Double>>(100);
    ArrayList<Double> lambdas = new ArrayList<Double>();

    for (double mu0 = start; mu0 < (mu_guess + 2); mu0 += step) {
        for (double sigma0 = start; sigma0 < (sigma_guess + 2); sigma0 += step) {
            LinkedHashMap<String, Double> answer = cc.newtonRaphson(data, mu0, sigma0, m);

            if (answer.get("lambda") != null) {
                ArrayList<Double> row = new ArrayList<Double>();

                row.add(mu0);
                row.add(sigma0);
                row.add(answer.get("lambda"));
                row.add(answer.get("mu"));
                row.add(answer.get("sigma"));
                row.add(answer.get("iterations"));

                matrix.add(row);

                boolean isUnique = true;
                for (double l : lambdas) {
                    if ((answer.get("lambda") < 0) || Math.abs(l - answer.get("lambda")) < 1e-2) {
                        isUnique = false;
                        break;
                    }
                }
                if (isUnique) {
                    LinkedHashMap<String, Double> s = new LinkedHashMap<String, Double>();
                    s.put("lambda", answer.get("lambda"));
                    s.put("mu", answer.get("mu"));
                    s.put("sigma", answer.get("sigma"));

                    solutions.add(s);
                }

                lambdas.add(answer.get("lambda"));
            }
        }
    }

    printMatrix(matrix, matrix_headers);
    System.out.println("Unique Solutions:");
    System.out.println(solutions.toString());

    if (!wasAlreadyRun && solutions.isEmpty())
        return newtonRaphson_ConvergenceTest(data, start, mu_guess, sigma_guess, .1, m, true);
    else
        return solutions;
}

From source file:com.dangdang.ddframe.job.cloud.scheduler.mesos.TaskInfoData.java

/**
 * ?./*w w  w  . j a va2s .  c  o  m*/
 * 
 * @return ??
 */
public byte[] serialize() {
    LinkedHashMap<String, Object> result = new LinkedHashMap<>(2, 1);
    result.put("shardingContext", shardingContexts);
    result.put("jobConfigContext", buildJobConfigurationContext());
    return SerializationUtils.serialize(result);
}