List of usage examples for java.util Map isEmpty
boolean isEmpty();
From source file:ext.deployit.community.cli.plainarchive.config.ConfigParser.java
private static List<ConfigurationItemMatcher> parseRules(Properties config, RuleParser parser) { List<ConfigurationItemMatcher> matchers = newLinkedList(); Map<String, String> configProperties = fromProperties(config); int maxNumRules = config.size() / MIN_PROPERTIES_PER_RULE; // rules are numbered beginning with 1 for (int i = 1; i <= maxNumRules; i++) { Map<String, String> nthRuleProperties = new RulePropertiesCollector(i).apply(configProperties); if (nthRuleProperties.isEmpty()) { // only support consecutive numbering break; }//from w w w .j a v a 2 s . c o m matchers.add(parser.apply(nthRuleProperties)); } return matchers; }
From source file:com.ewcms.common.lang.EmptyUtil.java
/** * Map//from w ww. j av a 2 s. c o m * * @param value * @return */ public static boolean isMapEmpty(Map<?, ?> value) { if (isNull(value)) { return true; } return value.isEmpty(); }
From source file:com.xebialabs.deployit.cli.ext.mustachify.config.ConfigParser.java
private static List<DarEntryTransformer> parseTransforms(Properties config, TransformParser parser) { List<DarEntryTransformer> matchers = newLinkedList(); Map<String, String> configProperties = fromProperties(config); // rules are numbered beginning with 1 for (int i = 1; i <= MAX_NUM_TRANSFORMERS; i++) { Map<String, String> nthTransformProperties = new RulePropertiesCollector(i).apply(configProperties); if (nthTransformProperties.isEmpty()) { // only support consecutive numbering break; }// w ww . ja va2 s. com matchers.add(parser.apply(nthTransformProperties)); } return matchers; }
From source file:io.confluent.kafkarest.converters.AvroConverter.java
private static Schema getSchema(Object value) { if (value instanceof GenericContainer) { return ((GenericContainer) value).getSchema(); } else if (value instanceof Map) { // This case is unusual -- the schema isn't available directly anywhere, instead we have to // take get the value schema out of one of the entries and then construct the full schema. Map mapValue = ((Map) value); if (mapValue.isEmpty()) { // In this case the value schema doesn't matter since there is no content anyway. This // only works because we know in this case that we are only using this for conversion and // no data will be added to the map. return Schema.createMap(primitiveSchemas.get("Null")); }// w ww. j a v a2 s . c o m Schema valueSchema = getSchema(mapValue.values().iterator().next()); return Schema.createMap(valueSchema); } else if (value == null) { return primitiveSchemas.get("Null"); } else if (value instanceof Boolean) { return primitiveSchemas.get("Boolean"); } else if (value instanceof Integer) { return primitiveSchemas.get("Integer"); } else if (value instanceof Long) { return primitiveSchemas.get("Long"); } else if (value instanceof Float) { return primitiveSchemas.get("Float"); } else if (value instanceof Double) { return primitiveSchemas.get("Double"); } else if (value instanceof String) { return primitiveSchemas.get("String"); } else if (value instanceof byte[] || value instanceof ByteBuffer) { return primitiveSchemas.get("Bytes"); } throw new ConversionException("Couldn't determine Schema from object"); }
From source file:org.activiti.rest.content.service.api.HttpMultipartHelper.java
public static HttpEntity getMultiPartEntity(String fileName, String contentType, InputStream fileStream, Map<String, String> additionalFormFields) throws IOException { MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); if (additionalFormFields != null && !additionalFormFields.isEmpty()) { for (Entry<String, String> field : additionalFormFields.entrySet()) { entityBuilder.addTextBody(field.getKey(), field.getValue()); }//from w w w. j a v a 2 s.c o m } entityBuilder.addBinaryBody(fileName, IOUtils.toByteArray(fileStream), ContentType.create(contentType), fileName); return entityBuilder.build(); }
From source file:com.github.itoshige.testrail.client.TestRailClient.java
/************ results ************/ public static JSONArray addResults(TestResultStoreKey runId2Class) { Map<String, List<Map<String, Object>>> results = SyncManager.getJunitTestResults(runId2Class); if (results.isEmpty()) return new JSONArray(); logger.info("update testrail. runId:{}", runId2Class.getRunId()); return (JSONArray) post(String.format("add_results/%s", runId2Class.getRunId()), results); }
From source file:edu.purdue.cybercenter.dm.util.JsonTransformer.java
private static Object applyDirective(Map<String, Object> directive, Object data, Map<String, Object> context) { if (directive == null || directive.isEmpty()) { throw new RuntimeException("empty directive"); }//from w w w .j a v a2s . co m if (directive.size() != 1) { throw new RuntimeException("invalid directive format: " + Helper.deepSerialize(directive)); } String name = directive.keySet().iterator().next(); Map<String, Object> definition = (Map<String, Object>) directive.get(name); switch (name) { case JsonTransformer.JSON_DIRECTIVE_MERGE: data = jsonMerge(definition, data, context); break; default: } return data; }
From source file:com.pkrete.xrd4j.rest.util.ClientUtil.java
/** * Builds the target URL based on the given based URL and parameters Map. * @param url base URL// w w w. j a va 2 s. c om * @param params URL parameters * @return comlete URL containing the base URL with all the parameters * appended */ public static String buildTargetURL(String url, Map<String, String> params) { logger.debug("Target URL : \"{}\".", url); if (params == null || params.isEmpty()) { logger.debug("URL parameters list is null or empty. Nothing to do here. Return target URL."); return url; } if (params.containsKey("resourceId")) { logger.debug("Resource ID found from parameters map. Resource ID value : \"{}\".", params.get("resourceId")); if (!url.endsWith("/")) { url += "/"; } url += params.get("resourceId"); params.remove("resourceId"); logger.debug("Resource ID added to URL : \"{}\".", url); } StringBuilder paramsString = new StringBuilder(); for (String key : params.keySet()) { if (paramsString.length() > 0) { paramsString.append("&"); } paramsString.append(key).append("=").append(params.get(key)); logger.debug("Parameter : \"{}\"=\"{}\"", key, params.get(key)); } if (!url.contains("?") && !params.isEmpty()) { url += "?"; } else if (url.contains("?") && !params.isEmpty()) { if (!url.endsWith("?") && !url.endsWith("&")) { url += "&"; } } url += paramsString.toString(); logger.debug("Request parameters added to URL : \"{}\".", url); return url; }
From source file:Main.java
/** * Creates a tag from the given string values. Can be used for creating html or xml tags. * /* w w w . j ava 2s . co m*/ * @param tagname * the tagname * @param value * the value from the tag. * @param attributtes * a map with the attributtes * @return the string */ public static String newTag(final String tagname, final String value, final Map<String, String> attributtes) { final StringBuilder xmlTag = new StringBuilder(); xmlTag.append("<").append(tagname); if (attributtes != null && !attributtes.isEmpty()) { xmlTag.append(" "); int count = 1; for (final Map.Entry<String, String> attributte : attributtes.entrySet()) { xmlTag.append(attributte.getKey()); xmlTag.append("="); xmlTag.append("\"").append(attributte.getValue()).append("\""); if (count != attributtes.size()) { xmlTag.append(" "); } count++; } } xmlTag.append(">"); xmlTag.append(value); xmlTag.append("</").append(tagname).append(">"); return xmlTag.toString(); }
From source file:com.l2jfree.gameserver.instancemanager.RaidPointsManager.java
public static int getPointsByOwnerId(int ownerId) { Map<Integer, Integer> tmpPoint = _list.get(ownerId); if (tmpPoint == null || tmpPoint.isEmpty()) return 0; int totalPoints = 0; for (int points : tmpPoint.values()) totalPoints += points;/*w w w . ja v a 2s . c o m*/ return totalPoints; }