use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project dropwizard by dropwizard.
the class Size method parse.
@JsonCreator
public static Size parse(String size) {
final Matcher matcher = SIZE_PATTERN.matcher(size);
if (!matcher.matches()) {
throw new IllegalArgumentException("Invalid size: " + size);
}
final long count = Long.parseLong(matcher.group(1));
final SizeUnit unit = SUFFIXES.get(matcher.group(2));
if (unit == null) {
throw new IllegalArgumentException("Invalid size: " + size + ". Wrong size unit");
}
return new Size(count, unit);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project dropwizard by dropwizard.
the class Duration method parse.
@JsonCreator
public static Duration parse(String duration) {
final Matcher matcher = DURATION_PATTERN.matcher(duration);
if (!matcher.matches()) {
throw new IllegalArgumentException("Invalid duration: " + duration);
}
final long count = Long.parseLong(matcher.group(1));
final TimeUnit unit = SUFFIXES.get(matcher.group(2));
if (unit == null) {
throw new IllegalArgumentException("Invalid duration: " + duration + ". Wrong time unit");
}
return new Duration(count, unit);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project graylog2-server by Graylog2.
the class IndexSetConfig method create.
@JsonCreator
public static IndexSetConfig create(@Id @ObjectId @JsonProperty("_id") @Nullable String id, @JsonProperty("title") @NotBlank String title, @JsonProperty("description") @Nullable String description, @JsonProperty("writable") @Nullable Boolean isWritable, @JsonProperty(FIELD_REGULAR) @Nullable Boolean isRegular, @JsonProperty(FIELD_INDEX_PREFIX) @Pattern(regexp = INDEX_PREFIX_REGEX) String indexPrefix, @JsonProperty("index_match_pattern") @Nullable String indexMatchPattern, @JsonProperty("index_wildcard") @Nullable String indexWildcard, @JsonProperty("shards") @Min(1) int shards, @JsonProperty("replicas") @Min(0) int replicas, @JsonProperty("rotation_strategy_class") @Nullable String rotationStrategyClass, @JsonProperty("rotation_strategy") @NotNull RotationStrategyConfig rotationStrategy, @JsonProperty("retention_strategy_class") @Nullable String retentionStrategyClass, @JsonProperty("retention_strategy") @NotNull RetentionStrategyConfig retentionStrategy, @JsonProperty(FIELD_CREATION_DATE) @NotNull ZonedDateTime creationDate, @JsonProperty("index_analyzer") @Nullable String indexAnalyzer, @JsonProperty("index_template_name") @Nullable String indexTemplateName, @JsonProperty(FIELD_INDEX_TEMPLATE_TYPE) @Nullable String indexTemplateType, @JsonProperty("index_optimization_max_num_segments") @Nullable Integer maxNumSegments, @JsonProperty("index_optimization_disabled") @Nullable Boolean indexOptimizationDisabled, @JsonProperty("field_type_refresh_interval") @Nullable Duration fieldTypeRefreshInterval) {
final boolean writableValue = isWritable == null ? true : isWritable;
Duration fieldTypeRefreshIntervalValue = fieldTypeRefreshInterval;
if (fieldTypeRefreshIntervalValue == null) {
// No need to periodically refresh the field types for a non-writable index set
fieldTypeRefreshIntervalValue = writableValue ? DEFAULT_FIELD_TYPE_REFRESH_INTERVAL : Duration.ZERO;
}
return AutoValue_IndexSetConfig.builder().id(id).title(title).description(description).isWritable(writableValue).isRegular(isRegular).indexPrefix(indexPrefix).indexMatchPattern(indexMatchPattern).indexWildcard(indexWildcard).shards(shards).replicas(replicas).rotationStrategyClass(rotationStrategyClass).rotationStrategy(rotationStrategy).retentionStrategyClass(retentionStrategyClass).retentionStrategy(retentionStrategy).creationDate(creationDate).indexAnalyzer(isNullOrEmpty(indexAnalyzer) ? "standard" : indexAnalyzer).indexTemplateName(isNullOrEmpty(indexTemplateName) ? indexPrefix + "-template" : indexTemplateName).indexTemplateType(indexTemplateType).indexOptimizationMaxNumSegments(maxNumSegments == null ? 1 : maxNumSegments).indexOptimizationDisabled(indexOptimizationDisabled == null ? false : indexOptimizationDisabled).fieldTypeRefreshInterval(fieldTypeRefreshIntervalValue).build();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project graylog2-server by Graylog2.
the class MongoIndexRange method create.
@JsonCreator
public static MongoIndexRange create(@JsonProperty("_id") @Id @Nullable ObjectId id, @JsonProperty(FIELD_INDEX_NAME) String indexName, @JsonProperty(FIELD_BEGIN) long beginMillis, @JsonProperty(FIELD_END) long endMillis, @JsonProperty(FIELD_CALCULATED_AT) long calculatedAtMillis, @JsonProperty(FIELD_TOOK_MS) int calculationDuration, @JsonProperty(FIELD_STREAM_IDS) @Nullable List<String> streamIds) {
final DateTime begin = new DateTime(beginMillis, DateTimeZone.UTC);
final DateTime end = new DateTime(endMillis, DateTimeZone.UTC);
final DateTime calculatedAt = new DateTime(calculatedAtMillis, DateTimeZone.UTC);
return create(id, indexName, begin, end, calculatedAt, calculationDuration, streamIds);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project graylog2-server by Graylog2.
the class RegexWhitelistEntry method create.
@JsonCreator
public static RegexWhitelistEntry create(@JsonProperty("id") String id, @JsonProperty("title") String title, @JsonProperty("value") String value) {
// compile the pattern early so that we can catch illegal expressions asap
final Pattern pattern;
try {
pattern = Pattern.compile(value, Pattern.DOTALL);
} catch (PatternSyntaxException e) {
throw new IllegalArgumentException("Cannot create whitelist entry for invalid regular expression '" + value + "': " + e.getMessage(), e);
}
final RegexWhitelistEntry whitelistEntry = new AutoValue_RegexWhitelistEntry(id, Type.REGEX, title, value);
whitelistEntry.pattern = pattern;
return whitelistEntry;
}
Aggregations