/** * If S3Key filter is set make sure it has at least one rule */ private void validateS3KeyFilter(S3KeyFilter s3KeyFilter) { if (CollectionUtils.isNullOrEmpty(s3KeyFilter.getFilterRules())) { throw new SdkClientException("Cannot have an S3KeyFilter without any filter rules"); } }
/** * Joins a collection of strings with the given separator into a single string. * * @param toJoin Collection containing items to join. * @param separator String to join items with. * @return Empty string if collection is null or empty. Otherwise joins all strings in the collection with the separator. */ public static String join(Collection<String> toJoin, String separator) { if (isNullOrEmpty(toJoin)) { return ""; } StringBuilder joinedString = new StringBuilder(); int currentIndex = 0; for (String s : toJoin) { if(s != null) { joinedString.append(s); } if (currentIndex++ != toJoin.size() - 1) { joinedString.append(separator); } } return joinedString.toString(); } }
/** * Asserts the collection is not null and not empty, reporting to {@link ProblemReporter} with this context if it is. * * @param collection Collection to assert on. * @param propertyName Name of property. */ public void assertNotEmpty(Collection<?> collection, String propertyName) { if (CollectionUtils.isNullOrEmpty(collection)) { problemReporter.report(new Problem(this, String.format("%s requires one or more items", propertyName))); } }
private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
private void addInventoryOptionalFields(XmlWriter xml, List<String> optionalFields) { if (CollectionUtils.isNullOrEmpty(optionalFields)) { return; } xml.start("OptionalFields"); for (String field : optionalFields) { xml.start("Field").value(field).end(); } xml.end(); }
private static void assertStorage(Storage actual, StorageDescriptor expected) { assertEquals(actual.getLocation(), expected.getLocation()); assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary()); assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat()); assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat()); if (!isNullOrEmpty(expected.getBucketColumns())) { HiveBucketProperty bucketProperty = actual.getBucketProperty().get(); assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns()); assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue()); } } }
@Override public ResultStatus call() throws Exception { if (events == null || CollectionUtils.isNullOrEmpty(events.getEventList())) { throw new IllegalArgumentException("SequentialEvents does not contain any event to run"); } for (SingleEvent singleEvent : events.getEventList()) { new Backoff(singleEvent.getIntervalTimeInMs()).backoff(); singleEvent.getAction().execute(); } return ResultStatus.DONE; } });
/** * Joins a collection of strings with the given separator into a single string. * * @param toJoin Collection containing items to join. * @param separator String to join items with. * @return Empty string if collection is null or empty. Otherwise joins all strings in the collection with the separator. */ public static String join(Collection<String> toJoin, String separator) { if (isNullOrEmpty(toJoin)) { return ""; } StringBuilder joinedString = new StringBuilder(); int currentIndex = 0; for (String s : toJoin) { if(s != null) { joinedString.append(s); } if (currentIndex++ != toJoin.size() - 1) { joinedString.append(separator); } } return joinedString.toString(); } }
private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
public List<String> getSubnets() { return CollectionUtils.isNullOrEmpty(subnets) ? new ArrayList<String>() : subnets; }
public List<String> getSecurityGroups() { return CollectionUtils.isNullOrEmpty(securityGroups) ? new ArrayList<String>() : securityGroups; }
/** * If S3Key filter is set make sure it has at least one rule */ private void validateS3KeyFilter(S3KeyFilter s3KeyFilter) { if (CollectionUtils.isNullOrEmpty(s3KeyFilter.getFilterRules())) { throw new SdkClientException("Cannot have an S3KeyFilter without any filter rules"); } }
private void validate(List<LambdaFunction> lambdaFunctions) throws MojoExecutionException { if (isNullOrEmpty(lambdaFunctions)) { getLog().error("At least one function has to be provided in configuration"); throw new MojoExecutionException("Illegal configuration. Configuration for at least one Lambda function has to be provided"); } } }
@SuppressWarnings("unused") public boolean isSuccess() { if (!CollectionUtils.isNullOrEmpty(resultList)) { for (Result r : this.resultList) { if (!r.isSuccess()) { return false; } } return true; } else { return false; } }
/** * Asserts the collection is not null and not empty, reporting to {@link ProblemReporter} with this context if it is. * * @param collection Collection to assert on. * @param propertyName Name of property. */ public void assertNotEmpty(Collection<?> collection, String propertyName) { if (CollectionUtils.isNullOrEmpty(collection)) { problemReporter.report(new Problem(this, String.format("%s requires one or more items", propertyName))); } }
@Override public GetRecordsResult accept() { nextIterator = result.getNextShardIterator(); if (!CollectionUtils.isNullOrEmpty(result.getRecords())) { lastKnownSequenceNumber = Iterables.getLast(result.getRecords()).getSequenceNumber(); } if (nextIterator == null) { isShardEndReached = true; } return getResult(); }
private void addInventoryOptionalFields(XmlWriter xml, List<String> optionalFields) { if (CollectionUtils.isNullOrEmpty(optionalFields)) { return; } xml.start("OptionalFields"); for (String field : optionalFields) { xml.start("Field").value(field).end(); } xml.end(); }
private static void assertStorage(Storage actual, StorageDescriptor expected) { assertEquals(actual.getLocation(), expected.getLocation()); assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary()); assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat()); assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat()); if (!isNullOrEmpty(expected.getBucketColumns())) { HiveBucketProperty bucketProperty = actual.getBucketProperty().get(); assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns()); assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue()); } } }
private static void assertStorage(Storage actual, StorageDescriptor expected) { assertEquals(actual.getLocation(), expected.getLocation()); assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary()); assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat()); assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat()); if (!isNullOrEmpty(expected.getBucketColumns())) { HiveBucketProperty bucketProperty = actual.getBucketProperty().get(); assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns()); assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue()); } } }
private static void assertStorage(Storage actual, StorageDescriptor expected) { assertEquals(actual.getLocation(), expected.getLocation()); assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary()); assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat()); assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat()); if (!isNullOrEmpty(expected.getBucketColumns())) { HiveBucketProperty bucketProperty = actual.getBucketProperty().get(); assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns()); assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue()); } } }