Java Code Examples for com.fasterxml.jackson.annotation.JsonCreator

The following examples show how to use com.fasterxml.jackson.annotation.JsonCreator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: data-transfer-project   Source File: PhotoModel.java    License: Apache License 2.0 6 votes vote down vote up
@JsonCreator
public PhotoModel(
    @JsonProperty("title") String title,
    @JsonProperty("fetchableUrl") String fetchableUrl,
    @JsonProperty("description") String description,
    @JsonProperty("mediaType") String mediaType,
    @JsonProperty("dataId") String dataId,
    @JsonProperty("albumId") String albumId,
    @JsonProperty("inTempStore") boolean inTempStore) {
  this.title = title;
  this.fetchableUrl = fetchableUrl;
  this.description = description;
  this.mediaType = mediaType;
  if (dataId == null || dataId.isEmpty()) {
    throw new IllegalArgumentException("dataID must be set");
  }
  this.dataId = dataId;
  this.albumId = albumId;
  this.inTempStore = inTempStore;
}
 
Example 2
@Builder
@JsonCreator
private JSONNotificationTarget(
		@JsonProperty("targetType") @NonNull final UserNotificationTargetType targetType,
		@JsonProperty("windowId") final String windowId,
		@JsonProperty("documentId") final String documentId,
		@JsonProperty("viewId") final String viewId)
{
	this.targetType = targetType;

	this.windowId = windowId;
	this.documentType = windowId;
	this.documentId = documentId;

	this.viewId = viewId;
}
 
Example 3
Source Project: tasmo   Source File: ModelPath.java    License: Apache License 2.0 6 votes vote down vote up
@JsonCreator
public ModelPath(
        @JsonProperty("id") String id,
        @JsonProperty("pathMembers") List<ModelPathStep> pathMembers) {
    this.id = id;
    this.pathMembers = pathMembers;

    boolean assignedRootId = false;
    for (int i = 0; i < this.pathMembers.size(); i++) {
        ModelPathStep member = pathMembers.get(i);
        if (member.getIsRootId()) {
            if (assignedRootId) {
                throw new RuntimeException("should only have one root id declared, check " + member.toString());
            } else {
                this.rootIdIndex = i;
                assignedRootId = true;
            }
        }
    }
    if (!assignedRootId) {
        throw new IllegalStateException("ModelPath must have a root id.");
    }
}
 
Example 4
Source Project: batfish   Source File: AutocompleteSuggestion.java    License: Apache License 2.0 6 votes vote down vote up
@JsonCreator
private static @Nonnull AutocompleteSuggestion create(
    @Nullable @JsonProperty(PROP_TEXT) String text,
    @Nullable @JsonProperty(PROP_SUGGESTION_TYPE) SuggestionType suggestionType,
    @JsonProperty(PROP_IS_PARTIAL) boolean isPartial,
    @Nullable @JsonProperty(PROP_DESCRIPTION) String description,
    @JsonProperty(PROP_RANK) int rank,
    @JsonProperty(PROP_INSERTION_INDEX) int insertionIndex,
    @Nullable @JsonProperty(PROP_HINT) String hint) {
  return new AutocompleteSuggestion(
      firstNonNull(text, ""),
      firstNonNull(suggestionType, SuggestionType.UNKNOWN),
      isPartial,
      description,
      rank,
      insertionIndex,
      hint);
}
 
Example 5
Source Project: docker-client   Source File: RegistryConfigs.java    License: Apache License 2.0 6 votes vote down vote up
@JsonCreator
public static RegistryConfigs create(final Map<String, RegistryAuth> configs) {
  if (configs == null) {
    return empty();
  }

  // need to add serverAddress to each RegistryAuth instance; it is not available when
  // Jackson is deserializing the RegistryAuth field
  final Map<String, RegistryAuth> transformedMap = Maps.transformEntries(configs,
      new Maps.EntryTransformer<String, RegistryAuth, RegistryAuth>() {
        @Override
        public RegistryAuth transformEntry(final String key, final RegistryAuth value) {
          if (value == null) {
            return null;
          }
          if (value.serverAddress() == null) {
            return value.toBuilder()
                .serverAddress(key)
                .build();
          }
          return value;
        }
      });

  return builder().configs(transformedMap).build();
}
 
Example 6
Source Project: besu   Source File: BlockData.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public BlockData(
    @JsonProperty("number") final Optional<String> number,
    @JsonProperty("parentHash") final Optional<String> parentHash,
    @JsonProperty("coinbase") final Optional<String> coinbase,
    @JsonProperty("extraData") final Optional<String> extraData,
    @JsonProperty("transactions") final List<TransactionData> transactions) {
  this.number = number.map(UInt256::fromHexString).map(UInt256::toLong);
  this.parentHash = parentHash.map(Bytes32::fromHexString).map(Hash::wrap);
  this.coinbase = coinbase.map(Address::fromHexString);
  this.extraData = extraData.map(Bytes::fromHexStringLenient);
  this.transactionData = transactions;
}
 
Example 7
Source Project: docker-client   Source File: Container.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
static Container create(
    @JsonProperty("Id") final String id,
    @JsonProperty("Names") final List<String> names,
    @JsonProperty("Image") final String image,
    @JsonProperty("ImageID") final String imageId,
    @JsonProperty("Command") final String command,
    @JsonProperty("Created") final Long created,
    @JsonProperty("State") final String state,
    @JsonProperty("Status") final String status,
    @JsonProperty("Ports") final List<PortMapping> ports,
    @JsonProperty("Labels") final Map<String, String> labels,
    @JsonProperty("SizeRw") final Long sizeRw,
    @JsonProperty("SizeRootFs") final Long sizeRootFs,
    @JsonProperty("NetworkSettings") final NetworkSettings networkSettings,
    @JsonProperty("Mounts") final List<ContainerMount> mounts) {
  final ImmutableMap<String, String> labelsT = labels == null
                                               ? null : ImmutableMap.copyOf(labels);
  final ImmutableList<ContainerMount> mountsT = mounts == null
                                                ? null : ImmutableList.copyOf(mounts);
  final ImmutableList<String> namesT = names == null
          ? null : ImmutableList.copyOf(names);
  final ImmutableList<PortMapping> portsT = ports == null
          ? null : ImmutableList.copyOf(ports);

  return new AutoValue_Container(id, namesT, image, imageId, command,
      created, state, status, portsT, labelsT, sizeRw,
      sizeRootFs, networkSettings, mountsT);
}
 
Example 8
Source Project: Bats   Source File: MergeJoinPOP.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public MergeJoinPOP(
    @JsonProperty("left") PhysicalOperator left,
    @JsonProperty("right") PhysicalOperator right,
    @JsonProperty("conditions") List<JoinCondition> conditions,
    @JsonProperty("joinType") JoinRelType joinType
) {
  super(left, right, joinType, false, null, conditions);
  Preconditions.checkArgument(joinType != null, "Join type is missing!");
  Preconditions.checkArgument(joinType != JoinRelType.FULL,
    "Full outer join not currently supported with Merge Join");
}
 
Example 9
Source Project: restdocs-wiremock   Source File: NotePatchInput.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public NotePatchInput(@JsonProperty("title") String title,
		@JsonProperty("body") String body, @JsonProperty("tags") List<URI> tagUris) {
	this.title = title;
	this.body = body;
	this.tagUris = tagUris == null ? Collections.<URI>emptyList() : tagUris;
}
 
Example 10
Source Project: openapi-generator   Source File: Order.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static StatusEnum fromValue(String value) {
  for (StatusEnum b : StatusEnum.values()) {
    if (b.value.equals(value)) {
      return b;
    }
  }
  throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
 
Example 11
Source Project: docker-client   Source File: Driver.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
static Driver create(
    @JsonProperty("Name") final String name,
    @JsonProperty("Options") final Map<String, String> options) {
  final Builder builder = builder()
      .name(name);

  if (options != null) {
    builder.options(options);
  }

  return builder.build();
}
 
Example 12
Source Project: dcos-commons   Source File: DefaultResourceSpec.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
protected DefaultResourceSpec(
    @JsonProperty("name") String name,
    @JsonProperty("value") Protos.Value value,
    @JsonProperty("role") String role,
    @JsonProperty("pre-reserved-role") String preReservedRole,
    @JsonProperty("principal") String principal)
{
  this.name = name;
  this.value = value;
  this.role = role;
  this.preReservedRole = preReservedRole == null ? Constants.ANY_ROLE : preReservedRole;
  this.principal = principal;
}
 
Example 13
Source Project: batfish   Source File: If.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
@Nonnull
private static If jsonCreator(
    @Nullable @JsonProperty(PROP_ACTIONS) List<Statement> actions,
    @Nullable @JsonProperty(PROP_TRUE_STATEMENTS) BoolExpr matchCondition) {
  checkArgument(matchCondition != null, "Missing %s", PROP_TRUE_STATEMENTS);
  return new If(matchCondition, firstNonNull(actions, ImmutableList.of()));
}
 
Example 14
Source Project: eventeum   Source File: ParameterType.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static ParameterType build(String type) {
    final ParameterType paramType = new ParameterType();
    paramType.setType(type);

    return paramType;
}
 
Example 15
Source Project: openapi-generator   Source File: EnumTest.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static EnumNumberEnum fromValue(Double value) {
  for (EnumNumberEnum b : EnumNumberEnum.values()) {
    if (b.value.equals(value)) {
      return b;
    }
  }
  throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
 
Example 16
Source Project: Singularity   Source File: SingularityPortMapping.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public SingularityPortMapping(
  @JsonProperty("hostPort") int hostPort,
  @JsonProperty("containerPort") int containerPort,
  @JsonProperty("protocol") Optional<String> protocol
) {
  this.hostPort = hostPort;
  this.containerPort = containerPort;
  this.protocol = protocol;
}
 
Example 17
@JsonCreator
public IntervalParameters(
            @JsonProperty("sets") Set<IntervalSet> sets,
            @JsonProperty("intervals") List<Interval> intervals)
{
    this.sets = sets;
    this.intervals = intervals;
}
 
Example 18
Source Project: dremio-oss   Source File: IcebergTableProps.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public IcebergTableProps(
  @JsonProperty("tableLocation") String tableLocation,
  @JsonProperty("uuid") String uuid,
  @JsonProperty("fullSchema") BatchSchema fullSchema,
  @JsonProperty("partitionColumnNames") List<String> partitionColumnNames,
  @JsonProperty("icebergOpType") IcebergOperation.Type icebergOpType
  ) {
    this.tableLocation = tableLocation;
    this.uuid = uuid;
    this.fullSchema = fullSchema;
    this.partitionColumnNames = partitionColumnNames;
    this.icebergOpType = icebergOpType;
}
 
Example 19
Source Project: NLIWOD   Source File: EJAnswers.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@JsonCreator
public static EJAnswers factory(final String json) {
	try {
		return new ObjectMapper().readValue(json, EJAnswers.class);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
}
 
Example 20
Source Project: ffwd   Source File: ProtocolFactory.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public ProtocolFactory(
    @JsonProperty("type") String type, @JsonProperty("host") String host,
    @JsonProperty("port") Integer port,
    @JsonProperty("receiveBufferSize") Integer receiveBufferSize
) {
    this.type = type;
    this.host = host;
    this.port = port;
    this.receiveBufferSize = receiveBufferSize;
}
 
Example 21
Source Project: blynk-server   Source File: DailyReport.java    License: GNU General Public License v3.0 5 votes vote down vote up
@JsonCreator
public DailyReport(@JsonProperty("atTime") long atTime,
                   @JsonProperty("durationType") ReportDurationType durationType,
                   @JsonProperty("startTs") long startTs,
                   @JsonProperty("endTs")long endTs) {
    this.atTime = atTime;
    this.durationType = durationType;
    this.startTs = startTs;
    this.endTs = endTs;
}
 
Example 22
Source Project: onos   Source File: Bmv2PreJsonGroups.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public L1Handle(@JsonProperty("handle") int handle,
                @JsonProperty("l2_handle") int l2handle,
                @JsonProperty("rid") int rid) {
    this.handle = handle;
    this.l2handle = l2handle;
    this.rid = rid;
}
 
Example 23
Source Project: openapi-generator   Source File: EnumTest.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static EnumNumberEnum fromValue(Double value) {
  for (EnumNumberEnum b : EnumNumberEnum.values()) {
    if (b.value.equals(value)) {
      return b;
    }
  }
  throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
 
Example 24
Source Project: openapi-generator   Source File: MapTest.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static InnerEnum fromValue(String value) {
  for (InnerEnum b : InnerEnum.values()) {
    if (b.value.equals(value)) {
      return b;
    }
  }
  throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
 
Example 25
Source Project: vespa   Source File: InstanceInformation.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public Endpoint(@JsonProperty("cluster") String cluster ,
                @JsonProperty("tls") boolean tls,
                @JsonProperty("url") URI url,
                @JsonProperty("scope") String scope,
                @JsonProperty("routingMethod") RoutingMethod routingMethod) {
    this.cluster = cluster;
    this.tls = tls;
    this.url = url;
    this.scope = scope;
    this.routingMethod = routingMethod;
}
 
Example 26
@JsonCreator
public static ImportCount create(
        @JsonProperty(IMPORTED) Integer imported,
        @JsonProperty(UPDATED) Integer updated,
        @JsonProperty(DELETED) Integer deleted,
        @JsonProperty(IGNORED) Integer ignored) {
    return new AutoValue_ImportCount(imported, updated, deleted, ignored);
}
 
Example 27
Source Project: openapi-generator   Source File: InlineObject2.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public static EnumFormStringEnum fromValue(String value) {
  for (EnumFormStringEnum b : EnumFormStringEnum.values()) {
    if (b.value.equals(value)) {
      return b;
    }
  }
  throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
 
Example 28
Source Project: druid-api   Source File: TimestampSpec.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public TimestampSpec(
    @JsonProperty("column") String timestampColumn,
    @JsonProperty("format") String format,
    // this value should never be set for production data
    @JsonProperty("missingValue") DateTime missingValue
)
{
  this.timestampColumn = (timestampColumn == null) ? DEFAULT_COLUMN : timestampColumn;
  this.timestampFormat = format == null ? DEFAULT_FORMAT : format;
  this.timestampConverter = TimestampParser.createObjectTimestampParser(timestampFormat);
  this.missingValue = missingValue == null
                                     ? DEFAULT_MISSING_VALUE
                                     : missingValue;
}
 
Example 29
Source Project: Singularity   Source File: SingularityRequestWithState.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public SingularityRequestWithState(
  @JsonProperty("request") SingularityRequest request,
  @JsonProperty("state") RequestState state,
  @JsonProperty("timestamp") long timestamp
) {
  this.request = request;
  this.state = state;
  this.timestamp = timestamp;
}
 
Example 30
Source Project: batfish   Source File: MinorIssueConfig.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
private static @Nonnull MinorIssueConfig create(
    @JsonProperty(PROP_MINOR_ISSUE) @Nullable String minorIssue,
    @JsonProperty(PROP_SEVERITY) @Nullable Integer severity,
    @JsonProperty(PROP_URL) @Nullable String url) {
  return new MinorIssueConfig(
      requireNonNull(minorIssue, "'minorIssue' cannot be null"), severity, url);
}