Refine search
/** * * @return if this entity has failed validation. This will also check the {@link #getPropertyValidationErrors()} map and * {@link #getGlobalValidationErrors()} if this boolean has not been explicitly set */ public boolean isValidationFailure() { if (MapUtils.isNotEmpty(getPropertyValidationErrors()) || CollectionUtils.isNotEmpty(getGlobalValidationErrors())) { isValidationFailure = true; } return isValidationFailure; }
/** * Null-safe check if the specified map is not empty. * <p> * Null returns false. * * @param map the map to check, may be null * @return true if non-null and non-empty * @since Commons Collections 3.2 */ public static boolean isNotEmpty(Map map) { return !MapUtils.isEmpty(map); }
private String replaceDefaultKeywordForMerge(String valueClause, Table table, ASTNode columnListNode) throws SemanticException { if (!valueClause.toLowerCase().contains("`default`")) { return valueClause; } Map<String, String> colNameToDefaultConstraint = getColNameToDefaultValueMap(table); String[] values = valueClause.trim().split(","); String[] replacedValues = new String[values.length]; // the list of the column names may be set in the query String[] columnNames = columnListNode == null ? table.getAllCols().stream().map(f -> f.getName()).toArray(size -> new String[size]) : columnListNode.getChildren().stream().map(n -> ((ASTNode)n).toString()).toArray(size -> new String[size]); for (int i = 0; i < values.length; i++) { if (values[i].trim().toLowerCase().equals("`default`")) { replacedValues[i] = MapUtils.getString(colNameToDefaultConstraint, columnNames[i], "null"); } else { replacedValues[i] = values[i]; } } return StringUtils.join(replacedValues, ','); }
/** * Add extra configurations (if any) as a String component to the domain XML */ protected void addExtraConfigComponent(Map<String, String> extraConfig, LibvirtVMDef vm) { if (MapUtils.isNotEmpty(extraConfig)) { StringBuilder extraConfigBuilder = new StringBuilder(); for (String key : extraConfig.keySet()) { if (!key.startsWith(DPDK_INTERFACE_PREFIX)) { extraConfigBuilder.append(extraConfig.get(key)); } } String comp = extraConfigBuilder.toString(); if (org.apache.commons.lang.StringUtils.isNotBlank(comp)) { vm.addComp(comp); } } }
private boolean isValidMap(Map map) { Object guid = map.get(AtlasObjectId.KEY_GUID); if (guid != null && StringUtils.isNotEmpty(guid.toString())) { return true; } else { Object typeName = map.get(AtlasObjectId.KEY_TYPENAME); if (typeName != null && StringUtils.isNotEmpty(typeName.toString())) { Object uniqueAttributes = map.get(AtlasObjectId.KEY_UNIQUE_ATTRIBUTES); if (uniqueAttributes instanceof Map && MapUtils.isNotEmpty((Map) uniqueAttributes)) { return true; } } } return false; } }
private Map<String, String> mapRequestClaimsInStandardDialect(Map<String, String> requestedClaimMappings, Map<String, String> carbonToStandardClaimMapping) { if (MapUtils.isEmpty(requestedClaimMappings)) { return new HashMap<>(); } return requestedClaimMappings.entrySet().stream().filter(mapping -> StringUtils. isNotBlank(carbonToStandardClaimMapping.get(mapping.getValue()))).collect(Collectors. toMap(mapping -> carbonToStandardClaimMapping.get(mapping.getValue()), mapping -> mapping. getValue())); }
/** * {@inheritDoc} */ @Override protected boolean prove(T value) { if (value instanceof String) { return StringUtils.isNotEmpty((String) value); } else if (value instanceof Collection) { return CollectionUtils.isNotEmpty((Collection<?>) value); } else if (value instanceof Map) { return MapUtils.isNotEmpty((Map<?, ?>) value); } else { throw new RuntimeException("The isNotEmpty Validator not used with String, Collection or Map object. Passed object is " + value); } }
@Override public NativeDocument process(final NativeDocument input) { if (MapUtils.isNotEmpty(attachmentQueryMap)) { for (Attachment<?> attachment : input.getAttachments().values()) { if (isPathAccepted(attachment.getId())) { List<String> invalidPaths = new ArrayList<String>(); processSingleAttachment(input, attachment, invalidPaths); if (!invalidPaths.isEmpty()) { attachment.addTagByKey(PROPERTY_INVALID_PATHS, StringUtils.join(invalidPaths, ";")); } } } } return input; }
public static void asyncHttpPost(String url, List<String> headers, Map<String, String> paramValues, AsyncCompletionHandler handler) throws Exception { AsyncHttpClient.BoundRequestBuilder builder = asyncHttpClient.preparePost(url); if (!CollectionUtils.isEmpty(headers)) { for (String header : headers) { builder.setHeader(header.split("=")[0], header.split("=")[1]); } } if (!MapUtils.isEmpty(paramValues)) { FluentStringsMap params = new FluentStringsMap(); for (Map.Entry<String, String> entry : paramValues.entrySet()) { params.put(entry.getKey(), Collections.singletonList(entry.getValue())); } builder.setParameters(params); } builder.setHeader("Accept-Charset", "UTF-8"); if (handler != null) { builder.execute(handler); } else { builder.execute(); } }
if (MapUtils.isEmpty(propertyErrors) && CollectionUtils.isEmpty(globalErrors)) { return true; if (MapUtils.isNotEmpty(propertyErrors)) { for (Map.Entry<String, List<String>> pe : propertyErrors.entrySet()) { for (String errorMessage : pe.getValue()) { if (CollectionUtils.isNotEmpty(globalErrors)) { for (String errorMessage : globalErrors) { errors.reject(errorMessage, errorMessage);
private static void addBucketFileToResults2(HashMap<String, FileStatus> taskIDToFile, int numBuckets, Configuration hconf, List<Path> result) { if (MapUtils.isNotEmpty(taskIDToFile) && (numBuckets > taskIDToFile.size()) && !"tez".equalsIgnoreCase(hconf.get(ConfVars.HIVE_EXECUTION_ENGINE.varname))) { addBucketsToResultsCommon(taskIDToFile, numBuckets, result); } }
/** * Looks up the given key in the given map, converting the result into * a string, using the default value if the the conversion fails. * * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a string, or defaultValue if the * original value is null, the map is null or the string conversion * fails */ public static String getString( Map map, Object key, String defaultValue ) { String answer = getString( map, key ); if ( answer == null ) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * an integer, using the default value if the the conversion fails. * * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion * fails */ public static Integer getInteger( Map map, Object key, Integer defaultValue ) { Integer answer = getInteger( map, key ); if ( answer == null ) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a long, using the default value if the the conversion fails. * * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion * fails */ public static Long getLong( Map map, Object key, Long defaultValue ) { Long answer = getLong( map, key ); if ( answer == null ) { answer = defaultValue; } return answer; }
@Test public void testRemoveNamespaces() throws Exception { Map props = new HashMap(); props.put("blah.booleanProperty", "true"); props.put("blah.blah.doubleProperty", NumberFormat.getInstance().format(0.124)); props.put("blah.blah.Blah.intProperty", "14"); props.put("longProperty", "999999999"); props.put("3456.stringProperty", "string"); props = PropertiesUtils.removeNamespaces(props); assertTrue(getBooleanValue(props, "booleanProperty", false)); assertEquals(0.124, 0, getDoubleValue(props, "doubleProperty", 0)); assertEquals(14, getIntValue(props, "intProperty", 0)); assertEquals(999999999, 0, getLongValue(props, "longProperty", 0)); assertEquals("string", getString(props, "stringProperty", "")); }
/** Create the keyspace */ private void createKeySpace( String keyspace ) { logger.info( "Creating keyspace: {}", keyspace ); String strategy_class = getString( properties, "cassandra.keyspace.strategy", "org.apache.cassandra.locator.SimpleStrategy" ); logger.info( "Using strategy: {}", strategy_class ); int replication_factor = getIntValue( properties, "cassandra.keyspace.replication", 1 ); logger.info( "Using replication (may be overriden by strategy options): {}", replication_factor ); // try { ThriftKsDef ks_def = ( ThriftKsDef ) HFactory .createKeyspaceDefinition( keyspace, strategy_class, replication_factor, new ArrayList<ColumnFamilyDefinition>() ); @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, String> strategy_options = filter( ( Map ) properties, "cassandra.keyspace.strategy.options.", true ); if ( strategy_options.size() > 0 ) { logger.info( "Strategy options: {}", mapToFormattedJsonString( strategy_options ) ); ks_def.setStrategyOptions( strategy_options ); } cluster.addKeyspace( ks_def ); waitForCreation( keyspace ); logger.info( "Created keyspace {}", keyspace ); }
private List<String> getRequestVars() { if(MapUtils.isNotEmpty(this.params) && this.params.get(REQUEST_VARS) instanceof String) { String requestVars = (String) this.params.get(REQUEST_VARS); if(StringUtils.isNotBlank(requestVars)) { return Arrays.asList(requestVars.split(",")); } } return null; }
private boolean isValidMap(Map map) { Object guid = map.get(AtlasObjectId.KEY_GUID); if (guid != null && StringUtils.isNotEmpty(guid.toString())) { return true; } else { Object typeName = map.get(AtlasObjectId.KEY_TYPENAME); if (typeName != null && StringUtils.isNotEmpty(typeName.toString())) { Object uniqueAttributes = map.get(AtlasObjectId.KEY_UNIQUE_ATTRIBUTES); if (uniqueAttributes instanceof Map && MapUtils.isNotEmpty((Map) uniqueAttributes)) { return true; } } } return false; } }
private Map<String, String> mapRequestClaimsInStandardDialect(Map<String, String> requestedClaimMappings, Map<String, String> carbonToStandardClaimMapping) { if (MapUtils.isEmpty(requestedClaimMappings)) { return new HashMap<>(); } return requestedClaimMappings.entrySet().stream().filter(mapping -> StringUtils. isNotBlank(carbonToStandardClaimMapping.get(mapping.getValue()))).collect(Collectors. toMap(mapping -> carbonToStandardClaimMapping.get(mapping.getValue()), mapping -> mapping. getValue())); }