List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:de.cubeisland.engine.core.module.ModuleInfo.java
ModuleInfo(Core core) { this.path = Paths.get("CubeEngine.jar"); this.sourceVersion = core.getSourceVersion(); if (core instanceof BukkitCore) { this.main = ((BukkitCore) core).getDescription().getMain(); } else {// ww w .j av a2s. c om this.main = ""; } this.id = CoreModule.ID; this.name = CoreModule.NAME; this.description = "This is the core meta module."; this.version = core.getVersion(); this.minCoreVersion = core.getVersion(); this.dependencies = Collections.emptyMap(); this.softDependencies = this.dependencies; this.pluginDependencies = Collections.emptySet(); this.loadAfter = this.pluginDependencies; this.services = Collections.emptySet(); this.softServices = Collections.emptySet(); this.providedServices = Collections.emptySet(); }
From source file:de.johni0702.minecraft.gui.layout.GridLayout.java
@Override public Map<GuiElement, Pair<ReadablePoint, ReadableDimension>> layOut(GuiContainer<?> container, ReadableDimension size) {// w ww . ja v a2 s . c o m Preconditions.checkState(columns != 0, "Columns may not be 0."); int elements = container.getElements().size(); int rows = (elements - 1 + columns) / columns; if (rows < 1) { return Collections.emptyMap(); } int cellWidth = (size.getWidth() + spacingX) / columns - spacingX; int cellHeight = (size.getHeight() + spacingY) / rows - spacingY; Pair<int[], int[]> maxCellSize = null; if (!cellsEqualSize) { maxCellSize = calcNeededCellSize(container); } Map<GuiElement, Pair<ReadablePoint, ReadableDimension>> map = new LinkedHashMap<>(); Iterator<Map.Entry<GuiElement, LayoutData>> iter = container.getElements().entrySet().iterator(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (!iter.hasNext()) { return map; } int x = j * (cellWidth + spacingX); int y = i * (cellHeight + spacingY); if (maxCellSize != null) { cellWidth = maxCellSize.getLeft()[j]; cellHeight = maxCellSize.getRight()[i]; x = 0; for (int x1 = 0; x1 < j; x1++) { x += maxCellSize.getLeft()[x1]; x += spacingX; } y = 0; for (int y1 = 0; y1 < i; y1++) { y += maxCellSize.getRight()[y1]; y += spacingY; } } Map.Entry<GuiElement, LayoutData> entry = iter.next(); GuiElement element = entry.getKey(); Data data = entry.getValue() instanceof Data ? (Data) entry.getValue() : DEFAULT_DATA; Dimension elementSize = new Dimension(element.getMinSize()); ReadableDimension elementMaxSize = element.getMaxSize(); elementSize.setWidth(Math.min(cellWidth, elementMaxSize.getWidth())); elementSize.setHeight(Math.min(cellHeight, elementMaxSize.getHeight())); int remainingWidth = cellWidth - elementSize.getWidth(); int remainingHeight = cellHeight - elementSize.getHeight(); x += (int) (data.alignmentX * remainingWidth); y += (int) (data.alignmentY * remainingHeight); map.put(element, Pair.<ReadablePoint, ReadableDimension>of(new Point(x, y), elementSize)); } } return map; }
From source file:de.uniulm.omi.cloudiator.visor.rest.entities.SensorMonitorDto.java
public Map<String, String> getSensorConfiguration() { if (sensorConfiguration == null) { return Collections.emptyMap(); }/*from w w w .j a va 2s . c o m*/ return sensorConfiguration; }
From source file:com.android.volley.toolbox.UploadNetwork.java
@Override public NetworkResponse performRequest(Request<?> request) throws VolleyError { long requestStart = SystemClock.elapsedRealtime(); while (true) { HttpResponse httpResponse = null; byte[] responseContents = null; Map<String, String> responseHeaders = Collections.emptyMap(); RandomAccessFile acessfile = null; File file = null;//w ww. j a va 2s .c o m try { if (!(request instanceof DownOrUpRequest)) { throw new IllegalArgumentException("request object mast be DownOrUpRequest???"); } DownOrUpRequest requestDown = (DownOrUpRequest) request; // Gather headers. Map<String, String> headers = new HashMap<String, String>(); // Download have no cache String url = requestDown.getUrl(); String name = url.substring(url.lastIndexOf('/'), url.length()); String path = requestDown.getDownloadPath(); String filePath = ""; if (path.endsWith("/")) { filePath = path + name; } else { path = path + "/"; filePath = path + "/" + name; } File dir = new File(path); dir.mkdirs(); file = File.createTempFile(path, null, dir); acessfile = new RandomAccessFile(file, "rws"); long length = acessfile.length(); acessfile.seek(length); // Range: bytes=5275648- headers.put("Range", "bytes=" + length + "-");// httpResponse = mHttpStack.performRequest(requestDown, headers); StatusLine statusLine = httpResponse.getStatusLine(); int statusCode = statusLine.getStatusCode(); responseHeaders = convertHeaders(httpResponse.getAllHeaders()); // if the request is slow, log it. long requestLifetime = SystemClock.elapsedRealtime() - requestStart; logSlowRequests(requestLifetime, requestDown, responseContents, statusLine); if (statusCode < 200 || statusCode > 299) { acessfile.close(); throw new IOException(); } // Some responses such as 204s do not have content. We must check. if (httpResponse.getEntity() != null) { responseContents = entityToBytes(httpResponse.getEntity(), requestDown, acessfile); } else { // Add 0 byte response as a way of honestly representing a // no-content request. responseContents = new byte[0]; } acessfile.close(); file.renameTo(new File(filePath)); return new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart); } catch (SocketTimeoutException e) { attemptRetryOnException("socket", request, new TimeoutError()); } catch (ConnectTimeoutException e) { attemptRetryOnException("connection", request, new TimeoutError()); } catch (MalformedURLException e) { throw new RuntimeException("Bad URL " + request.getUrl(), e); } catch (IOException e) { if (acessfile != null) { try { acessfile.close(); file.delete(); } catch (IOException e1) { e1.printStackTrace(); } } int statusCode = 0; NetworkResponse networkResponse = null; if (httpResponse != null) { statusCode = httpResponse.getStatusLine().getStatusCode(); } else { throw new NoConnectionError(e); } VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl()); throw new NetworkError(networkResponse); } } }
From source file:org.elasticsearch.multi_node.GlobalCheckpointSyncActionIT.java
public void testGlobalCheckpointSyncActionRunsAsPrivilegedUser() throws Exception { // create the test-index index try (XContentBuilder builder = jsonBuilder()) { builder.startObject();/*from w w w .j a va 2s. c om*/ { builder.startObject("settings"); { builder.field("index.number_of_shards", 1); builder.field("index.number_of_replicas", 1); } builder.endObject(); } builder.endObject(); final StringEntity entity = new StringEntity(Strings.toString(builder), ContentType.APPLICATION_JSON); client().performRequest("PUT", "test-index", Collections.emptyMap(), entity); } // wait for the replica to recover client().performRequest("GET", "/_cluster/health", Collections.singletonMap("wait_for_status", "green")); // index some documents final int numberOfDocuments = randomIntBetween(0, 128); for (int i = 0; i < numberOfDocuments; i++) { try (XContentBuilder builder = jsonBuilder()) { builder.startObject(); { builder.field("foo", i); } builder.endObject(); final StringEntity entity = new StringEntity(Strings.toString(builder), ContentType.APPLICATION_JSON); client().performRequest("PUT", "/test-index/test-type/" + i, Collections.emptyMap(), entity); } } // we have to wait for the post-operation global checkpoint sync to propagate to the replica assertBusy(() -> { final Map<String, String> params = new HashMap<>(2); params.put("level", "shards"); params.put("filter_path", "**.seq_no"); final Response response = client().performRequest("GET", "/test-index/_stats", params); final ObjectPath path = ObjectPath.createFromResponse(response); // int looks funny here since global checkpoints are longs but the response parser does not know enough to treat them as long final int shard0GlobalCheckpoint = path .evaluate("indices.test-index.shards.0.0.seq_no.global_checkpoint"); assertThat(shard0GlobalCheckpoint, equalTo(numberOfDocuments - 1)); final int shard1GlobalCheckpoint = path .evaluate("indices.test-index.shards.0.1.seq_no.global_checkpoint"); assertThat(shard1GlobalCheckpoint, equalTo(numberOfDocuments - 1)); }); }
From source file:io.github.carlomicieli.footballdb.starter.parsers.PlayerProfileParser.java
protected static Map<String, String> extractInfo(Optional<String> str) { return str.map(val -> { Matcher matcher = patternMatchString(infoPattern(), val); Map<String, String> v = newMap(); if (matcher.find()) { v.put("height", matcher.group(1)); v.put("weight", matcher.group(2)); v.put("age", matcher.group(3)); }/* w w w . j a v a 2 s . c o m*/ return unmodifiableMap(v); }).orElse(Collections.emptyMap()); }
From source file:com.haulmont.cuba.security.app.LoginServiceBean.java
@Override public UserSession loginTrusted(String login, String password, Locale locale) throws LoginException { return loginTrusted(login, password, locale, Collections.emptyMap()); }
From source file:com.haulmont.idp.controllers.IdpLoginManager.java
public IdpService.IdpLoginResult login(AuthRequest auth, Locale sessionLocale) throws LoginException { IdpAuthMode authenticationMode = authenticationConfig.getAuthenticationMode(); List<String> standardAuthenticationUsers = authenticationConfig.getStandardAuthenticationUsers(); if (standardAuthenticationUsers.contains(auth.getUsername())) { // user can only use STANDARD authentication authenticationMode = IdpAuthMode.STANDARD; }/*w w w . j ava 2 s . c om*/ switch (authenticationMode) { case STANDARD: { LoginPasswordCredentials credentials = new LoginPasswordCredentials(auth.getUsername(), passwordEncryption.getPlainHash(auth.getPassword()), sessionLocale); credentials.setClientType(ClientType.WEB); return idpService.login(credentials, Collections.emptyMap()); } case LDAP: { if (!authenticateInLdap(auth)) { throw new LoginException(messages.formatMainMessage("LoginException.InvalidLoginOrPassword", sessionLocale, auth.getUsername())); } TrustedClientCredentials credentials = new TrustedClientCredentials(auth.getUsername(), idpConfig.getTrustedClientPassword(), sessionLocale); credentials.setClientType(ClientType.WEB); return idpService.login(credentials, Collections.emptyMap()); } default: log.error("Unsupported authentication mode {}", authenticationConfig.getAuthenticationMode()); throw new LoginException(messages.formatMainMessage("LoginException.InvalidLoginOrPassword", sessionLocale, auth.getUsername())); } }
From source file:net.itransformers.utils.MyGraphMLWriter.java
/** * //from w w w . j a v a 2 s. com */ @SuppressWarnings("unchecked") public MyGraphMLWriter() { vertex_ids = new Transformer<V, String>() { public String transform(V v) { return v.toString(); } }; edge_ids = TransformerUtils.nullTransformer(); graph_data = Collections.emptyMap(); vertex_data = Collections.emptyMap(); edge_data = Collections.emptyMap(); vertex_desc = TransformerUtils.nullTransformer(); edge_desc = TransformerUtils.nullTransformer(); graph_desc = TransformerUtils.nullTransformer(); nest_level = 0; }
From source file:fr.gael.dhus.util.functional.collect.TransformedMapTest.java
/** Constructor: Empty map param. */ @Test/*w w w. ja v a 2s .c o m*/ public void emptyMapTest() { TransformedMap transformed_map = new TransformedMap(Collections.emptyMap(), trans); Assert.assertTrue(transformed_map.isEmpty()); Assert.assertEquals(transformed_map.size(), 0); Assert.assertFalse(transformed_map.keySet().iterator().hasNext()); Assert.assertFalse(transformed_map.values().iterator().hasNext()); Assert.assertFalse(transformed_map.entrySet().iterator().hasNext()); }