List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:$.LogParserConfig.java
public void setFilter(Map<String, String> filter) { if (filter == null) { this.filter = Collections.emptyMap(); } else {/*from w ww .j ava 2 s. c o m*/ this.filter = new LinkedHashMap<String, String>(filter); this.filter.keySet().retainAll(getPropertyNames()); } }
From source file:ddf.catalog.data.defaultvalues.DefaultAttributeValueRegistryImpl.java
@Override public Optional<Serializable> getDefaultValue(String metacardTypeName, String attributeName) { notNull(metacardTypeName, "The metacard type name cannot be null."); notNull(attributeName, "The attribute name cannot be null."); final Serializable globalDefault = globalDefaults.get(attributeName); final Serializable metacardDefault = metacardDefaults.getOrDefault(metacardTypeName, Collections.emptyMap()) .get(attributeName);/*from w ww . j av a2 s .co m*/ return Optional.ofNullable(metacardDefault != null ? metacardDefault : globalDefault); }
From source file:com.android.volley.toolbox.DownloadNetwork.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;//from w ww . j ava 2 s . 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 file = getFile(requestDown); acessfile = new RandomAccessFile(file, "rws"); long length = acessfile.length(); acessfile.seek(length); if (length != 0) { 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(); String re = null; if (!requestDown.isCanceled() || requestDown.getmMaxLength() == requestDown.getmCurLength()) { String path = file.getAbsolutePath(); String re_name = ((DownOrUpRequest) request).getmDownloadName(); if (re_name != null) { re = path.substring(0, path.lastIndexOf('/')) + "/" + re_name; } else { re = path.substring(0, path.lastIndexOf(".")); } File rename = new File(re); boolean result = file.renameTo(rename); if (!result) { Log.e(this.getClass().getName(), "?????:" + rename); throw new IOException( "????????"); } requestDown.setDownloadFile(rename); } else { re = file.getAbsolutePath(); statusCode = 209; } return new NetworkResponse(statusCode, re.getBytes(), 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:grails.util.GrailsWebUtil.java
/** * @return The currently bound GrailsApplication instance * @since 2.0/*from ww w . j a v a2s .c o m*/ */ public static Map currentFlatConfiguration() { GrailsApplication application = currentApplication(); return application == null ? Collections.emptyMap() : application.getFlatConfig(); }
From source file:org.trustedanalytics.servicebroker.yarn.config.ServiceInstanceBindingServiceConfig.java
private Map<String, Object> getCredentials() throws IOException { Optional<Map<String, String>> hadoopConf = HadoopConfigurationHelper .getHadoopConfFromJson(configuration.getYarnProvidedParams()); return ImmutableMap.of("kerberos", ImmutableMap.of("kerberos", ImmutableMap.of("kdc", configuration.getKerberosKdc(), "krealm", configuration.getKerberosRealm()), ConfigConstants.HADOOP_CONFIG_KEY_VALUE, ImmutableMap.copyOf(hadoopConf.orElse(Collections.emptyMap())))); }
From source file:org.elasticsearch.backwards.IndexingIT.java
private void createIndex(String name, Settings settings) throws IOException { assertOK(client().performRequest("PUT", name, Collections.emptyMap(), new StringEntity( "{ \"settings\": " + Strings.toString(settings) + " }", ContentType.APPLICATION_JSON))); }
From source file:com.espertech.esper.view.std.AddPropertyValueOptionalView.java
/** * Constructor./*from w ww.java2s.c o m*/ * @param propertyNames is the name of the field that is added to any events received by this view. * @param mergeValues is the values of the field that is added to any events received by this view. * @param mergedResultEventType is the event type that the merge view reports to it's child views * @param agentInstanceContext contains required view services */ public AddPropertyValueOptionalView(AgentInstanceViewFactoryChainContext agentInstanceContext, String[] propertyNames, Object mergeValues, EventType mergedResultEventType) { this.propertyNames = propertyNames; this.propertyValues = mergeValues; this.eventType = mergedResultEventType; this.agentInstanceContext = agentInstanceContext; this.newToOldEventMap = Collections.emptyMap(); }
From source file:io.mycat.config.loader.xml.XMLRuleLoader.java
public Map<String, TableRuleConfig> getTableRules() { return (Map<String, TableRuleConfig>) (tableRules.isEmpty() ? Collections.emptyMap() : tableRules); }
From source file:com.netflix.spinnaker.fiat.roles.file.FileBasedUserRolesProvider.java
@Override public Map<String, Collection<Role>> multiLoadRoles(Collection<String> userIds) { try {/*from w w w. jav a 2s .c o m*/ return parse().entrySet().stream().filter(e -> userIds.contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } catch (IOException io) { log.error("Couldn't mulitLoad roles from file", io); } return Collections.emptyMap(); }
From source file:de.pixida.logtest.tutorial.TutorialAutomatonsTest.java
private boolean getExecutionResultOfAutomatonOnTutorialLog(final String automatonName) { final String tutorialFolder = "/tutorial"; BufferedReader br = null;/* w ww . j a v a 2s . co m*/ try { br = new BufferedReader(new StringReader(FileUtils.readFileToString( new File(this.getClass().getResource(tutorialFolder + "/log.txt").getFile()), StandardCharsets.UTF_8))); } catch (final IOException e) { Assert.fail(e.getMessage()); } final LogSink sink = new LogSink(); try { sink.setAutomaton(new JsonAutomatonDefinition( new File(this.getClass().getResource(tutorialFolder + "/" + automatonName + ".json").toURI()))); } catch (final URISyntaxException e) { Assert.fail(e.getMessage()); } sink.setParameters(Collections.emptyMap()); final Job job = new Job(); job.setLogReader(new GenericLogReader(br)); job.setSinks(Arrays.asList(sink)); final JobExecutor jobExecutor = new JobExecutor(Arrays.asList(job)); final List<List<EvaluationResult>> results = jobExecutor.getResults(); Assert.assertEquals(1, results.size()); Assert.assertEquals(1, results.get(0).size()); return results.get(0).get(0).isSuccess(); }