Skip to content

Commit

Permalink
Implement #47
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 17, 2014
1 parent 83b0a64 commit 7d11014
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ NOTE: Annotations module will never contain changes in patch versions,

2.5.0 (not yet released)

#47: Add `@JsonCreatore.mode` property to explicitly choose between delegating- and property-based creators
- Added `@JsonInclude.content` to allow specifying inclusion criteria
for `java.util.Map` entries separate from inclusion of `Map` values
themselves
Expand Down
45 changes: 44 additions & 1 deletion src/main/java/com/fasterxml/jackson/annotation/JsonCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,48 @@
@JacksonAnnotation
public @interface JsonCreator
{
// no values, since there's no property
/**
* Property that is used to indicate how argument(s) is/are bound for creator,
* in cases there may be multiple alternatives. Currently the one case is that
* of a single-argument creator method, for which both so-called "delegating" and
* "property-based" bindings are possible: since
* delegating mode can not be used for multi-argument creators, the only choice
* there is "property-based" mode.
* Check {@link Mode} for more complete explanation of possible choices.
*<p>
* Default value of {@link Mode#DEFAULT} means that caller is to use standard
* heuristics for choosing mode to use.
*
* @since 2.5
*/
public Mode mode() default Mode.DEFAULT;

/**
* @since 2.5
*/
public enum Mode {
/**
* Pseudo-mode that indicates that caller is to use default heuristics for
* choosing mode to use. This typically favors use of delegating mode for
* single-argument creators that take structured types.
*/
DEFAULT,

/**
* Mode that indicates that if creator takes a single argument, the whole incoming
* data value is to be bound into declared type of that argument; this "delegate"
* value is then passed as the argument to creator.
*/
DELEGATING,

/**
* Mode that indicates that the argument(s) for creator are to be bound from matching
* properties of incoming Object value, using creator argument names (explicit or implicit)
* to match incoming Object properties to arguments.
*<p>
* Note that this mode is currently (2.5) always used for multiple-argument creators;
* the only ambiguous case is that of a single-argument creator.
*/
PROPERTIES
}
}

0 comments on commit 7d11014

Please sign in to comment.