javax.json.bind.annotation.JsonbCreator Java Examples

The following examples show how to use javax.json.bind.annotation.JsonbCreator. 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 File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #2
Source File: JsonbParser.java    From typescript-generator with MIT License 5 votes vote down vote up
private List<PropertyModel> visit(final Class<?> clazz) {
    return Stream.of(clazz.getConstructors())
            .filter(it -> it.isAnnotationPresent(JsonbCreator.class))
            .findFirst()
            .map(it -> new ArrayList<>(Stream.concat(visitConstructor(it), visitClass(clazz).stream())
                    .collect(Collectors.toMap(PropertyModel::getName, Function.identity(), (a, b) -> a)) // merge models
                    .values()))
            .orElseGet(() -> new ArrayList<>(visitClass(clazz)));
}
 
Example #3
Source File: Obstacle.java    From liberty-bikes with Eclipse Public License 1.0 5 votes vote down vote up
@JsonbCreator
public Obstacle(int w, int h, int x, int y) {
    this.height = h;
    this.width = w;
    this.x = x;
    this.y = y;
}
 
Example #4
Source File: Person.java    From microprofile-sandbox with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
              @JsonbProperty("age") int age,
              @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #5
Source File: Person.java    From microprofile-sandbox with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
              @JsonbProperty("age") int age,
              @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #6
Source File: Person.java    From microprofile-sandbox with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #7
Source File: Person.java    From microprofile-sandbox with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #8
Source File: Magazine.java    From Java-EE-8-Sampler with MIT License 5 votes vote down vote up
@JsonbCreator
public Magazine(@JsonbProperty("bookTitle") String title,
                @JsonbProperty("firstName") String firstName,
                @JsonbProperty("surname") String lastName) {
    this.title = title;
    this.authorName = new Author(firstName, lastName);
}
 
Example #9
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #10
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
              @JsonbProperty("age") int age,
              @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #11
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
              @JsonbProperty("age") int age,
              @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #12
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
              @JsonbProperty("age") int age,
              @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #13
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #14
Source File: Person.java    From microshed-testing with Apache License 2.0 5 votes vote down vote up
@JsonbCreator
public Person(@JsonbProperty("name") String name,
        @JsonbProperty("age") int age,
        @JsonbProperty("id") Long id) {
    this.name = name;
    this.age = age;
    this.id = id == null ? r.nextLong() : id;
}
 
Example #15
Source File: Example.java    From dsl-json with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@JsonbCreator
public WithCustomCtor(int x, int y) {
	this.x = x;
	this.y = y;
}
 
Example #16
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator
public ListOfNullableElementsConstructor(List<@Nullable String> foos) {
    this.foos = foos;
}
 
Example #17
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator
public ObjectWithRequiredPropertyAndConstructor(@RequiredAnnotation final String foo, final String bar) {}
 
Example #18
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator // we agree it is a stupid case but generator must respect user choice
public NillableConstructorParameter(@JsonbProperty(value = "foo", nillable = true) final int foo) {
    this.foo = foo;
}
 
Example #19
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator
public RequiredWithGetter(final int foo) {
    this.foo = foo;
}
 
Example #20
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator
public RequiredOptional(final OptionalInt foo) {
    this.foo = foo.orElse(1);
}
 
Example #21
Source File: JsonbParserTest.java    From typescript-generator with MIT License 4 votes vote down vote up
@JsonbCreator
public Required(final int foo) {
    this.foo = foo;
}
 
Example #22
Source File: Example.java    From dsl-json with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@JsonbCreator
public static ViaFactory create(String name, int num) {
	return new ViaFactory(name, num);
}
 
Example #23
Source File: Greeting.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@JsonbCreator
public Greeting(@JsonbProperty("message") String message, @JsonbProperty("date") LocalDate date) {
    this.message = message;
    this.date = date;
}
 
Example #24
Source File: Example.java    From dsl-json with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@JsonbCreator
Model() {}
 
Example #25
Source File: Player.java    From liberty-bikes with Eclipse Public License 1.0 4 votes vote down vote up
@JsonbCreator
public Player(@JsonbProperty("name") String name,
              @JsonbProperty("id") String id) {
    this(name, id, new PlayerStats());
}
 
Example #26
Source File: Book.java    From Java-EE-8-Sampler with MIT License 4 votes vote down vote up
@JsonbCreator
public static Book createBook(@JsonbProperty("id") String id,
                              @JsonbProperty("title") String title,
                              @JsonbProperty("author") String author) {
    return new Book(id, title, author);
}