Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:com.joyent.manta.domain.ErrorDetail.java

@Override
public Map<String, Object> asMap() {
    final Map<String, Object> attributes = new LinkedHashMap<>();

    if (getMessage() != null) {
        attributes.put("message", getMessage());
    }/*from  w  w  w . j  av  a  2 s.  co m*/

    if (getCode() != null) {
        attributes.put("code", getCode());
    }

    if (getErrors() != null) {
        attributes.put("errors", getErrors());
    }

    return Collections.unmodifiableMap(attributes);
}

From source file:com.teambr.modularsystems.core.registries.BlockValueRegistry.java

public BlockValueRegistry() {
    values = new LinkedHashMap<>();
    materialValues = new LinkedHashMap<>();
}

From source file:net.logstash.logback.composite.loggingevent.MdcJsonProviderTest.java

@Before
public void setup() {
    mdc = new LinkedHashMap<String, String>();
    mdc.put("name1", "value1");
    mdc.put("name2", "value2");
    mdc.put("name3", "value3");
    when(event.getMDCPropertyMap()).thenReturn(mdc);
}

From source file:io.pivotal.spring.cloud.service.eureka.EurekaServiceConnector.java

@Override
protected PropertySource<?> toPropertySource(EurekaServiceInfo eurekaServiceInfo) {
    Map<String, Object> map = new LinkedHashMap<>();
    map.put(EUREKA_CLIENT + "serviceUrl.defaultZone", eurekaServiceInfo.getUri() + EUREKA_API_PREFIX);
    map.put(EUREKA_CLIENT + "region", DEFAULT_REGION);
    map.put(EUREKA_CLIENT_OAUTH2 + "clientId", eurekaServiceInfo.getClientId());
    map.put(EUREKA_CLIENT_OAUTH2 + "clientSecret", eurekaServiceInfo.getClientSecret());
    map.put(EUREKA_CLIENT_OAUTH2 + "accessTokenUri", eurekaServiceInfo.getAccessTokenUri());
    return new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}

From source file:code.tianmao.h5.controller.BackendExceptionController.java

protected ModelAndView prepareExceptionInfo(HttpServletRequest request, HttpStatus httpStatus, String errorCode,
        String errorMessage) {//from  www  .  ja va 2s  .  c  o  m
    Map<String, Object> models = new LinkedHashMap<>();
    models.put("errorCode", errorCode);
    models.put("errorMessage", errorMessage);
    ModelAndView modelAndView = new ModelAndView();
    if (noNeedWrapper(request)) {
        modelAndView.setView(DEFAULT_JSON_VIEW);
        modelAndView.addAllObjects(models);
        return modelAndView;
    } else {
        modelAndView.setViewName("error");
        modelAndView.addAllObjects(models);
        return modelAndView;
    }
}

From source file:com.sugaronrest.restapicalls.methodcalls.GetLinkedEntry.java

/**
 * Gets linked entry[SugarCRM REST method - get_entry].
 *
 * @param url REST API Url./* w w  w.  ja va 2  s  .  c  o  m*/
 * @param sessionId Session identifier.
 * @param moduleName SugarCRM module name.
 * @param identifier The entity identifier.
 * @param selectFields Selected field list.
 * @param linkedSelectFields Linked field info.
 * @return ReadLinkedEntryResponse object
 */
public static ReadLinkedEntryResponse run(String url, String sessionId, String moduleName, String identifier,
        List<String> selectFields, List<Object> linkedSelectFields) {

    ReadLinkedEntryResponse readLinkedEntryResponse = null;
    ErrorResponse errorResponse = null;

    String jsonRequest = new String();
    String jsonResponse = new String();

    ObjectMapper mapper = JsonObjectMapper.getMapper();

    try {
        Map<String, Object> requestData = new LinkedHashMap<String, Object>();
        requestData.put("session", sessionId);
        requestData.put("module_name", moduleName);
        requestData.put("id", identifier);
        requestData.put("select_fields", selectFields);
        boolean linkedInfoNotSet = ((linkedSelectFields == null) || (linkedSelectFields.size() == 0));
        requestData.put("link_name_to_fields_array", linkedInfoNotSet ? StringUtils.EMPTY : linkedSelectFields);
        requestData.put("track_view", false);

        String jsonRequestData = mapper.writeValueAsString(requestData);

        Map<String, Object> request = new LinkedHashMap<String, Object>();
        request.put("method", "get_entry");
        request.put("input_type", "json");
        request.put("response_type", "json");
        request.put("rest_data", requestData);

        jsonRequest = mapper.writeValueAsString(request);

        request.put("rest_data", jsonRequestData);

        HttpResponse response = Unirest.post(url).fields(request).asString();

        if (response == null) {
            readLinkedEntryResponse = new ReadLinkedEntryResponse();
            errorResponse = ErrorResponse.format("An error has occurred!", "No data returned.");
            readLinkedEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            readLinkedEntryResponse.setError(errorResponse);
        } else {

            jsonResponse = response.getBody().toString();

            if (StringUtils.isNotBlank(jsonResponse)) {
                // First check if we have an error
                errorResponse = ErrorResponse.fromJson(jsonResponse);
                if (errorResponse == null) {
                    readLinkedEntryResponse = mapper.readValue(jsonResponse, ReadLinkedEntryResponse.class);
                }
            }

            if (readLinkedEntryResponse == null) {
                readLinkedEntryResponse = new ReadLinkedEntryResponse();
                readLinkedEntryResponse.setError(errorResponse);

                readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK);
                if (errorResponse != null) {
                    readLinkedEntryResponse.setStatusCode(errorResponse.getStatusCode());
                }
            } else {
                readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK);
            }
        }
    } catch (Exception exception) {
        readLinkedEntryResponse = new ReadLinkedEntryResponse();
        errorResponse = ErrorResponse.format(exception, exception.getMessage());
        readLinkedEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        readLinkedEntryResponse.setError(errorResponse);
    }

    readLinkedEntryResponse.setJsonRawRequest(jsonRequest);
    readLinkedEntryResponse.setJsonRawResponse(jsonResponse);

    return readLinkedEntryResponse;
}

From source file:com.lrs.enviroment.Metadata.java

private Metadata(File f) {
    metadataFile = f;
    delegateMap = new LinkedHashMap();
    loadFromFile(f);
}

From source file:com.opengamma.analytics.financial.interestrate.YieldCurveBundle.java

/**
 * Constructor. An empty map is created for the curves and an empty FXMatrix.
 *//*from w  w w  . j  a  v  a  2 s .co  m*/
public YieldCurveBundle() {
    _curves = new LinkedHashMap<>();
    _curveCurrency = new HashMap<>();
    _fxMatrix = new FXMatrix();
}

From source file:com.ikanow.aleph2.data_model.utils.TestJsonUtils.java

@Test
public void test_foldTuple() {
    final ObjectMapper mapper = BeanTemplateUtils.configureMapper(Optional.empty());

    LinkedHashMap<String, Object> test1 = new LinkedHashMap<String, Object>();
    test1.put("long", 10L);
    test1.put("double", 1.1);
    test1.put("string", "val");
    test1.put("json", "{\"misc\":true,\"long\":1, \"string\":\"\"}");

    final JsonNode j1 = JsonUtils.foldTuple(test1, mapper, Optional.empty());
    assertEquals("{\"misc\":true,\"long\":10,\"string\":\"val\",\"double\":1.1}", j1.toString());

    LinkedHashMap<String, Object> test2 = new LinkedHashMap<String, Object>();
    test2.put("misc", false);
    test2.put("long", 10L);
    test2.put("json", "{\"misc\":true,\"long\":1, \"string\":\"\"}");
    test2.put("double", 1.1);
    test2.put("string", "val");

    final JsonNode j2 = JsonUtils.foldTuple(test2, mapper, Optional.of("json"));
    assertEquals("{\"misc\":false,\"long\":10,\"string\":\"val\",\"double\":1.1}", j2.toString());

    LinkedHashMap<String, Object> test3 = new LinkedHashMap<String, Object>();
    test3.put("long", mapper.createObjectNode());
    test3.put("double", mapper.createArrayNode());
    test3.put("string", BeanTemplateUtils.build(TestBean.class).with("test1", 4).done().get());
    test3.put("json", "{\"misc\":true,\"long\":1, \"string\":\"\"}");

    final JsonNode j3 = JsonUtils.foldTuple(test3, mapper, Optional.of("json"));
    assertEquals("{\"misc\":true,\"long\":{},\"string\":{\"test1\":4},\"double\":[]}", j3.toString());

    LinkedHashMap<String, Object> test4 = new LinkedHashMap<String, Object>();
    test4.put("misc", BigDecimal.ONE);
    test4.put("long", (int) 10);
    test4.put("double", (float) 1.1);
    test4.put("json", "{\"misc\":true,\"long\":1, \"string\":\"\"}");
    test4.put("string", "val");

    final JsonNode j4 = JsonUtils.foldTuple(test4, mapper, Optional.of("json"));
    assertEquals("{\"misc\":1,\"long\":10,\"string\":\"val\",\"double\":1.1}",
            j4.toString().replaceFirst("1[.]1[0]{6,}[0-9]+", "1.1"));

    try {/*from  ww  w . ja  v a2  s  .c  om*/
        test4.put("json", "{\"misc\":true,\"long\":1, string\":\"\"}"); // (Added json error)
        JsonUtils.foldTuple(test4, mapper, Optional.of("json"));
        fail("Should have thrown JSON exception");
    } catch (Exception e) {
    } // json error, check

    new JsonUtils(); // (just for coverage)      
}

From source file:com.recomdata.export.ExportRowNew.java

public ExportRowNew() {
    values = new LinkedHashMap<String, String>();
}