private JsonbCreator createJsonbCreator(Executable executable, JsonbCreator existing, Class<?> clazz) { if (existing != null) { throw new JsonbException(Messages.getMessage(MessageKeys.MULTIPLE_JSONB_CREATORS, clazz)); } final Parameter[] parameters = executable.getParameters(); CreatorModel[] creatorModels = new CreatorModel[parameters.length]; for (int i=0; i<parameters.length; i++) { final Parameter parameter = parameters[i]; final JsonbProperty jsonbPropertyAnnotation = parameter.getAnnotation(JsonbProperty.class); if (jsonbPropertyAnnotation != null && !jsonbPropertyAnnotation.value().isEmpty()) { creatorModels[i] = new CreatorModel(jsonbPropertyAnnotation.value(), parameter, jsonbContext); } else { creatorModels[i] = new CreatorModel(parameter.getName(), parameter, jsonbContext); } } return new JsonbCreator(executable, creatorModels); }
@JsonbCreator public Magazine(@JsonbProperty("bookTitle") String title, @JsonbProperty("firstName") String firstName, @JsonbProperty("surname") String lastName) { this.title = title; this.authorName = new Author(firstName, lastName); }
private String getJsonbPropertyCustomizedName(Property property, JsonbAnnotatedElement<Method> methodElement) { JsonbProperty methodAnnotation = getMethodAnnotation(JsonbProperty.class, methodElement); if (methodAnnotation != null && !methodAnnotation.value().isEmpty()) { return methodAnnotation.value(); } //in case of property name getter/setter override field value JsonbProperty fieldAnnotation = getFieldAnnotation(JsonbProperty.class, property.getFieldElement()); if (fieldAnnotation != null && !fieldAnnotation.value().isEmpty()) { return fieldAnnotation.value(); } return null; }
@JsonbCreator public static Book createBook(@JsonbProperty("id") String id, @JsonbProperty("title") String title, @JsonbProperty("author") String author) { return new Book(id, title, author); }
@JsonbProperty("bookTitle") public String getTitle() { return title; }
@JsonbProperty("authorName") public void setAuthor(String author) { this.author = author; }
@JsonbProperty(nillable = true) public String getNillableOverride() { return nillableOverride; }
@JsonbProperty("propA") String getPropertyA();
@JsonbProperty("propA") void setPropertyA(String property);
@JsonbProperty("propC") String getPropertyC();
@JsonbProperty("propC") void setPropertyC(String propertyC);
@JsonbCreator CreatorPackagePrivateConstructor(@JsonbProperty("intVal") int intVal) { this.intVal = intVal; }
@JsonbCreator public CreatorWithoutJavabeanProperty(@JsonbProperty("s1") String s1, @JsonbProperty("s2") String s2) { this.strField = s1 + s2; }
@JsonbCreator public CreatorWithoutJsonbProperty(@JsonbProperty("s1") String par1, String par2, double d1) { this.par1 = par1; this.par2 = par2; this.par3 = d1; }
@JsonbCreator public CreatorWithoutJsonbProperty1(String par1, @JsonbProperty("s2") String par2, byte par3) { this.par1 = par1; this.par2 = par2; this.par3 = par3; }
@JsonbCreator public CreatorConstructorPojo(@JsonbProperty("str1") String str1, @JsonbProperty("str2") String str2) { this.str1 = str1; this.str2 = str2; }
@JsonbProperty("propB") String getPropertyB();
@JsonbProperty("propB") void setPropertyB(String propertyB);
@JsonbProperty(nillable = false) public String getNillableOverriddenWithGetterJsonbProperty() { return nillableOverriddenWithGetterJsonbProperty; }
@JsonbProperty(nillable = false) public void setNillableOverriddenWithSetterJsonbProperty(String nillableOverriddenWithSetterJsonbProperty) { this.nillableOverriddenWithSetterJsonbProperty = nillableOverriddenWithSetterJsonbProperty; }
@JsonbCreator public CreatorMultipleDeclarationErrorPojo(@JsonbProperty("val1") String s1) { this.s1 = s1; }
@JsonbCreator public static CreatorFactoryMethodPojo getInstance(@JsonbProperty("par1") String str1, @JsonbProperty("par2")String str2) { return new CreatorFactoryMethodPojo(str1, str2); }
@JsonbProperty("getterAnnotatedName") public String getMethodAnnotName() { return methodAnnotName; }
@JsonbProperty("setterAnnotatedName") public void setMethodAnnotName(String methodAnnotName) { this.methodAnnotName = methodAnnotName; }
@JsonbProperty("getterOverriddenName") public String getFieldOverriddenWithMethodAnnot() { return fieldOverriddenWithMethodAnnot; }
@JsonbProperty("setterOverriddenName") public void setFieldOverriddenWithMethodAnnot(String fieldOverriddenWithMethodAnnot) { this.fieldOverriddenWithMethodAnnot = fieldOverriddenWithMethodAnnot; }
@JsonbProperty("custom_name") public String getTransientProperty() { return transientProperty; }
@JsonbProperty("custom_name") public void setTransientProperty(String transientProperty) { this.transientProperty = transientProperty; }
@JsonbTransient @JsonbProperty("custom_name") public void setTransientProperty(String transientProperty) { this.transientProperty = transientProperty; }
@JsonbTransient @JsonbProperty("custom_name") public String getTransientProperty() { return transientProperty; }
@JsonbProperty("instance") public String getInstance() { return instance; }
@JsonbProperty("doi") public String getDOI() { return doi; }
@JsonbProperty("Doi") public String getDOI() { return doi; }
@JsonbCreator public DateConstructor(@JsonbProperty("localDate") @JsonbDateFormat(value = "dd-MM-yyyy", locale = "nl-NL") LocalDate localDate) { this.localDate = localDate; }
@JsonbCreator public DateConstructorMergedWithProperty(@JsonbProperty("localDate") LocalDate localDate) { this.localDate = localDate; }