use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project presto by prestodb.
the class NullableValue method fromSerializable.
// Jackson deserialization only
@JsonCreator
public static NullableValue fromSerializable(@JsonProperty("serializable") Serializable serializable) {
Type type = serializable.getType();
Block block = serializable.getBlock();
return new NullableValue(type, block == null ? null : Utils.blockToNativeValue(type, block));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project td-client-java by treasure-data.
the class TDQuery method fromObject.
@JsonCreator
public static TDQuery fromObject(JsonNode value) {
// embulk job have nested json object
try {
StringWriter s = new StringWriter();
new ObjectMapper().writeValue(s, value);
s.close();
return new TDQuery(s.toString());
} catch (java.io.IOException e) {
throw Throwables.propagate(e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project embulk by embulk.
the class ByteSize method parseByteSize.
@JsonCreator
public static ByteSize parseByteSize(String size) {
Preconditions.checkNotNull(size, "size is null");
Preconditions.checkArgument(!size.isEmpty(), "size is empty");
Matcher matcher = PATTERN.matcher(size);
if (!matcher.matches()) {
throw new IllegalArgumentException("Invalid byte size string '" + size + "'");
}
// NumberFormatException extends IllegalArgumentException.
double value = Double.parseDouble(matcher.group(1));
String unitString = matcher.group(2);
if (unitString.isEmpty()) {
return new ByteSize(value, Unit.BYTES);
} else {
String upperUnitString = unitString.toUpperCase(Locale.ENGLISH);
for (Unit unit : Unit.values()) {
if (unit.getUnitString().toUpperCase(Locale.ENGLISH).equals(upperUnitString)) {
return new ByteSize(value, unit);
}
}
}
throw new IllegalArgumentException("Unknown unit '" + unitString + "'");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project druid by druid-io.
the class InlineDataSource method fromJson.
/**
* Factory method for Jackson. Used for inline datasources that were originally encoded as JSON. Private because
* non-Jackson callers should use {@link #fromIterable}.
*/
@JsonCreator
private static InlineDataSource fromJson(@JsonProperty("columnNames") List<String> columnNames, @JsonProperty("columnTypes") List<ColumnType> columnTypes, @JsonProperty("rows") List<Object[]> rows) {
Preconditions.checkNotNull(columnNames, "'columnNames' must be nonnull");
if (columnTypes != null && columnNames.size() != columnTypes.size()) {
throw new IAE("columnNames and columnTypes must be the same length");
}
final RowSignature.Builder builder = RowSignature.builder();
for (int i = 0; i < columnNames.size(); i++) {
final String name = columnNames.get(i);
final ColumnType type = columnTypes != null ? columnTypes.get(i) : null;
builder.add(name, type);
}
return new InlineDataSource(rows, builder.build());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator in project batfish by batfish.
the class Prefix method parse.
@JsonCreator
public static Prefix parse(String text) {
String[] parts = text.split("/");
if (parts.length != 2) {
throw new BatfishException("Invalid prefix string: \"" + text + "\"");
}
Ip ip = new Ip(parts[0]);
int prefixLength;
try {
prefixLength = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
throw new BatfishException("Invalid prefix length: \"" + parts[1] + "\"", e);
}
return new Prefix(ip, prefixLength);
}
Aggregations