@Override public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) { field.annotate(JsonProperty.class).param("value", propertyName); if (field.type().erasure().equals(field.type().owner().ref(Set.class))) { field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class); } if (propertyNode.has("javaJsonView")) { field.annotate(JsonView.class).param( "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText())); } if (propertyNode.has("description")) { field.annotate(JsonPropertyDescription.class).param("value", propertyNode.get("description").asText()); } }
@JsonCreator public PublicKeyMirrorCredential(@JsonProperty("hostnamePatterns") @JsonDeserialize(contentAs = Pattern.class) Iterable<Pattern> hostnamePatterns, @JsonProperty("username") String username, @JsonProperty("publicKey") String publicKey, @JsonProperty("privateKey") String privateKey, @JsonProperty("passphrase") String passphrase) { super(hostnamePatterns); this.username = requireNonEmpty(username, "username"); requireNonEmpty(publicKey, "publicKey"); requireNonEmpty(privateKey, "privateKey"); this.publicKey = requireNonEmpty(publicKey, "publicKey").getBytes(StandardCharsets.UTF_8); this.privateKey = requireNonEmpty(privateKey, "privateKey").getBytes(StandardCharsets.UTF_8); this.passphrase = decodeBase64OrUtf8(passphrase, "passphrase"); }
@JsonCreator MultipleMirrorConfig( @JsonProperty("enabled") Boolean enabled, @JsonProperty("defaultSchedule") String defaultSchedule, @JsonProperty(value = "defaultDirection", required = true) MirrorDirection defaultDirection, @JsonProperty("defaultLocalPath") String defaultLocalPath, @JsonProperty(value = "includes", required = true) @JsonDeserialize(contentAs = MirrorInclude.class) Iterable<MirrorInclude> includes, @JsonProperty("excludes") @JsonDeserialize(contentAs = Pattern.class) Iterable<Pattern> excludes) { super(firstNonNull(enabled, true)); this.defaultSchedule = cronParser.parse(firstNonNull(defaultSchedule, DEFAULT_SCHEDULE)); this.defaultDirection = requireNonNull(defaultDirection, "defaultDirection"); this.defaultLocalPath = firstNonNull(defaultLocalPath, "/"); this.includes = ImmutableList.copyOf(requireNonNullElements(includes, "includes")); if (excludes != null) { this.excludes = ImmutableList.copyOf(requireNonNullElements(excludes, "excludes")); } else { this.excludes = Collections.emptyList(); } }
public AddJvmRequest(@JsonProperty(value = "id", required = true) @JsonDeserialize(using = UUIDDeserializer.class) @JsonSerialize(using = UUIDSerializer.class) UUID jvmId, @JsonProperty(value = "an_id", required = true) String analyseId, @JsonProperty(value = "name", required = true) String jvmName, @JsonProperty(value = "vm_ver", required = true) int vmVersion, @JsonProperty(value = "gc_type", required = true) int gcType, @JsonProperty("headers") String headers, @JsonProperty("mem") MemoryStatus memoryStatus) { this.jvmId = jvmId; this.analyseId = analyseId; this.jvmName = jvmName; this.vmVersion = vmVersion; this.gcType = gcType; this.headers = headers; this.memoryStatus = memoryStatus; }
@Test public void jacksonAnnotationAddedWithImplicitName() throws CannotGenerateCodeException { // See also https://github.com/google/FreeBuilder/issues/90 TypeElement dataType = model.newType( "package com.example;", "@" + JsonDeserialize.class.getName() + "(builder = DataType.Builder.class)", "public interface DataType {", " int getFooBar();", " class Builder extends DataType_Builder {}", "}"); Metadata metadata = analyser.analyse(dataType); Property property = getOnlyElement(metadata.getProperties()); assertPropertyHasJsonPropertyAnnotation(property, "fooBar"); }
@Test public void jsonAnyGetterAnnotationDisablesImplicitProperty() throws CannotGenerateCodeException { TypeElement dataType = model.newType( "package com.example;", "@" + JsonDeserialize.class.getName() + "(builder = DataType.Builder.class)", "public interface DataType {", " @" + JsonAnyGetter.class.getName(), " " + Map.class.getName() + "<Integer, String> getFooBar();", " class Builder extends DataType_Builder {}", "}"); Metadata metadata = analyser.analyse(dataType); Property property = getOnlyElement(metadata.getProperties()); assertThat(property.getAccessorAnnotations()).named("property accessor annotations").isEmpty(); }
@Test public void shouldCreateByteArrayFieldWithAnyEncoding() throws SecurityException, NoSuchFieldException { Field field = classWithMediaProperties.getDeclaredField("anyBinaryEncoding"); JsonSerialize serAnnotation = field.getAnnotation(JsonSerialize.class); JsonDeserialize deserAnnotation = field.getAnnotation(JsonDeserialize.class); assertThat("any binary encoding field has type byte[]", field.getType(), equalToType(BYTE_ARRAY)); assertThat("any binary encoding has a serializer", serAnnotation, notNullValue()); assertThat("any binary encoding has a deserializer", deserAnnotation, notNullValue()); }
@Override public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) { if( isQuotedPrintableProperty(propertyNode) ) { field.annotate(JsonSerialize.class).param(USING, QuotedPrintableSerializer.class); field.annotate(JsonInclude.class).param("value", JsonInclude.Include.NON_NULL); field.annotate(JsonDeserialize.class).param(USING, QuotedPrintableDeserializer.class); } }
@SuppressWarnings("deprecation") @Test public void noAnnotationsWorks() throws Exception { check(ImmutableJacksonMappedWithNoAnnotations.Json.class.getAnnotation(JsonDeserialize.class)).isNull(); String json = "{\"someString\":\"xxx\"}"; ImmutableJacksonMappedWithNoAnnotations value = OBJECT_MAPPER.readValue(json, ImmutableJacksonMappedWithNoAnnotations.class); check(OBJECT_MAPPER.writeValueAsString(value)).is(json); }
/** * Set the list of containing resources. Must all be instances of {@link SearchLayer} * * @throws IllegalArgumentException if at least one of the resources is not a {@link SearchLayer} */ @JsonDeserialize(contentAs = SearchLayer.class) @Override public void setWithin(List<Resource> within) throws IllegalArgumentException { if (within.stream().anyMatch(r -> !(r instanceof SearchLayer))) { throw new IllegalArgumentException("SearchResult can only be within a SearchLayer."); } super.setWithin(within); }
@JsonCreator public PasswordMirrorCredential(@JsonProperty("hostnamePatterns") @JsonDeserialize(contentAs = Pattern.class) Iterable<Pattern> hostnamePatterns, @JsonProperty("username") String username, @JsonProperty("password") String password) { super(hostnamePatterns); this.username = requireNonEmpty(username, "username"); this.password = requireNonNull(password, "password"); }
@JsonCreator CreateSessionCommand(@JsonProperty("timestamp") @Nullable Long timestamp, @JsonProperty("author") @Nullable Author author, @JsonProperty("session") @JsonDeserialize(using = SimpleSessionJsonDeserializer.class) SimpleSession session) { super(CommandType.CREATE_SESSION, timestamp, author); this.session = requireNonNull(session, "session"); }
@JsonCreator public static Dependencies create( @JsonProperty("options") final Options options, @JsonDeserialize(using = TableDeserializer.class) @JsonProperty("maven") final ImmutableTable<String, String, Maven> maven) { return builder().options(options).maven(maven == null ? ImmutableTable.of() : maven).build(); }
@Override @JsonSerialize(using = Jackson2HalModule.HalResourcesSerializer.class) @JsonDeserialize(using = Jackson2HalModule.HalResourcesDeserializer.class) public PagedIncidents getIncidentsPaged(int pagenum,int pagesize) { LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents"); final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents?page="+pagenum+"&size="+pagesize; ResponseEntity<PagedResources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null, new ParameterizedTypeReference<PagedResources<IncidentBean>>() {}); // LOG.info("Total Incidents {}", response.getBody().size()); PagedResources<IncidentBean> beanResources = response.getBody(); PagedIncidents incidents = new PagedIncidents(beanResources,pagenum); return incidents; }
@JsonCreator private Rule( @JsonProperty("capabilities") List<Capability> capabilities, @JsonProperty("min_wrapping_ttl") @JsonDeserialize(converter = StringToDurationConverter.class) Duration minWrappingTtl, @JsonProperty("max_wrapping_ttl") @JsonDeserialize(converter = StringToDurationConverter.class) Duration maxWrappingTtl, @JsonProperty("allowed_parameters") Map<String, List<String>> allowedParameters, @JsonProperty("denied_parameters") Map<String, List<String>> deniedParameters) { this.path = ""; this.capabilities = capabilities; this.minWrappingTtl = minWrappingTtl; this.maxWrappingTtl = maxWrappingTtl; this.allowedParameters = allowedParameters; this.deniedParameters = deniedParameters; }
/** * @param path the path to set */ @JsonDeserialize(using = JsonPointerDeserializer.class) public void setPath(JsonPointer path) { if (path == null) { throw new IllegalArgumentException("Path is null"); } this.path = path; }
/** * @param from the from to set */ @JsonDeserialize(using = JsonPointerDeserializer.class) public void setFrom(JsonPointer from) { if (from == null) { throw new IllegalArgumentException("From is null"); } this.from = from; }
/** * Constructor * * @param var name of variable * @param list list to iterate over * @param paths list of paths */ @JsonCreator public Repeat(@JsonProperty("var") String var, @JsonProperty("list") String list, @JsonProperty("paths") @JsonDeserialize(contentAs = Path.class) List<Path> paths, @JsonProperty("repeats") @JsonDeserialize(contentAs = Repeat.class) List<Repeat> repeats) { this.var = var; this.list = list; this.paths = ImmutableList.copyOf(paths != null ? paths : Collections.emptyList()); this.repeats = ImmutableList.copyOf(repeats != null ? repeats : Collections.emptyList()); }
/** * Constructor */ @JsonCreator public Config(@JacksonInject("location") URI location, @JsonProperty("includes") List<String> includes, @JsonProperty("properties") @JsonDeserialize(as = LinkedHashMap.class, keyAs = String.class, contentAs = String.class) Map<String, String> properties, @JsonProperty("paths") @JsonDeserialize(contentAs = Path.class) List<Path> paths, @JsonProperty("repeats") @JsonDeserialize(contentAs = Repeat.class) List<Repeat> repeats) { this(location, includes, properties == null ? null : ConfigUtil.mapToList(properties, Property::new), paths, repeats); }
/** * Constructor * * @param name name of path * @param value value of path * @param metrics metrics under this path * @param tags tags of this path as ordered map of tag key/value pairs * @param expectedCreationTime expression to calculate creation time of this path */ @JsonCreator public Path(@JsonProperty("name") String name, @JsonProperty("value") String value, @JsonProperty("metrics") @JsonDeserialize(contentAs = Metric.class) List<Metric> metrics, @JsonProperty("tags") @JsonDeserialize(as = LinkedHashMap.class, keyAs = String.class, contentAs = String.class) Map<String, String> tags, @JsonProperty("expectedCreationTime") String expectedCreationTime) { this(name, value, metrics, tags == null ? null : ConfigUtil.mapToList(tags, Tag::new), expectedCreationTime); }
@JsonProperty("features") @JsonDeserialize(contentUsing = FeatureCategoriesDeserializer.class) public List<String> getRetrieverCategories(){ Set<String> keys = this.retrieverCategories.keySet(); ArrayList<String> _return = new ArrayList<>(keys.size()); _return.addAll(keys); return _return; }
@JsonDeserialize(contentUsing = JobParametersDeserializer.class) public void setParameters(Map<String, Object> parameters) { this.parameters.clear(); if(parameters != null) { this.parameters.putAll(parameters); } }
@JsonCreator public InstanceConfirmation(@JsonProperty("provider") String provider, @JsonProperty("domain") String domain, @JsonProperty("service") String service, @JsonProperty("attestationData") @JsonDeserialize(using = SignedIdentityDeserializer.class) SignedIdentityDocument signedIdentityDocument) { this.provider = provider; this.domain = domain; this.service = service; this.signedIdentityDocument = signedIdentityDocument; }
@JsonProperty @JsonSerialize( using = JacksonPeriodSerializer.class ) @JsonDeserialize( using = JacksonPeriodDeserializer.class ) @JacksonXmlProperty( localName = "period", namespace = DxfNamespaces.DXF_2_0 ) public Period getPeriod() { return period; }
@JsonProperty @JsonSerialize( using = JacksonPeriodTypeSerializer.class ) @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @Property( PropertyType.TEXT ) public PeriodType getPeriodType() { return periodType; }
@Override @JsonProperty @JsonDeserialize( as = BaseDimensionalItemObject.class ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public DimensionalItemObject getValue() { return value; }
@JsonProperty @JsonSerialize( using = JacksonPeriodTypeSerializer.class ) @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public PeriodType getExpiryPeriodType() { return expiryPeriodType; }
@JsonProperty @JsonSerialize( contentUsing = JacksonPeriodSerializer.class ) @JsonDeserialize( contentUsing = JacksonPeriodDeserializer.class ) @JacksonXmlElementWrapper( localName = "periods", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "period", namespace = DxfNamespaces.DXF_2_0 ) public List<Period> getPeriods() { return periods; }
@Override @JsonProperty @JsonDeserialize( contentAs = BaseDimensionalObject.class ) @JacksonXmlElementWrapper( localName = "columns", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "column", namespace = DxfNamespaces.DXF_2_0 ) public List<DimensionalObject> getColumns() { return columns; }
@Override @JsonProperty @JsonDeserialize( contentAs = BaseDimensionalObject.class ) @JacksonXmlElementWrapper( localName = "rows", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "row", namespace = DxfNamespaces.DXF_2_0 ) public List<DimensionalObject> getRows() { return rows; }
@Override @JsonProperty @JsonDeserialize( contentAs = BaseDimensionalObject.class ) @JacksonXmlElementWrapper( localName = "filters", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "filter", namespace = DxfNamespaces.DXF_2_0 ) public List<DimensionalObject> getFilters() { return filters; }
@JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @JsonSerialize( using = CustomLastUpdatedUserSerializer.class ) @JsonDeserialize public User getLastUpdatedBy() { return lastUpdatedBy; }
@Override @JsonProperty @JsonDeserialize( contentAs = BaseDimensionalItemObject.class ) @JacksonXmlElementWrapper( localName = "items", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "item", namespace = DxfNamespaces.DXF_2_0 ) public List<DimensionalItemObject> getItems() { return items; }
@Override // @XmlElements({ // @XmlElement(type=OffsetTime.class), // @XmlElement(type=LocalTime.class) // }) @JsonDeserialize(using=TimeDeserializer.class) public TemporalAccessor getValue() { return value; }