diff options
author | Tatu Saloranta <tatu.saloranta@iki.fi> | 2019-10-08 17:18:19 -0700 |
---|---|---|
committer | Tatu Saloranta <tatu.saloranta@iki.fi> | 2019-10-08 17:18:19 -0700 |
commit | 85e7a3946e66618c241a98e6c772541280f0502d (patch) | |
tree | 6777aeeaae28f755d8d435b316cd59df8f4a9401 /src/main/java/com/fasterxml/jackson/databind/introspect | |
parent | 7db2de475debd1c320c7f7fe8085734ec9b9dbf9 (diff) | |
download | jackson-databind-85e7a3946e66618c241a98e6c772541280f0502d.tar.gz |
Add a method in SimpleMixInResolver for future optimizations
Diffstat (limited to 'src/main/java/com/fasterxml/jackson/databind/introspect')
-rw-r--r-- | src/main/java/com/fasterxml/jackson/databind/introspect/SimpleMixInResolver.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/SimpleMixInResolver.java b/src/main/java/com/fasterxml/jackson/databind/introspect/SimpleMixInResolver.java index a3c630a88..2e9560bda 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/SimpleMixInResolver.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/SimpleMixInResolver.java @@ -99,4 +99,33 @@ public class SimpleMixInResolver public int localSize() { return (_localMixIns == null) ? 0 : _localMixIns.size(); } + + /** + * Method that may be called for optimization purposes, to see if calls to + * mix-in resolver may be avoided. Return value of {@code true} means that + * it is possible that a mix-in class will be found; {@code false} that no + * mix-in will ever be found. In latter case caller can avoid calls altogether. + *<p> + * Note that the reason for "empty" resolvers is to use "null object" for simplifying + * code. + * + * @return True, if this resolver MAY have mix-ins to apply; false if not (it + * is "empty") + * + * @since 2.10.1 + */ + public boolean hasMixIns() { + if (_localMixIns == null) { + // if neither local mix-ins nor overrides, no mix-ins + if (_overrides == null) { + return false; + } + // or, if no local mix-ins and can delegate to resolver + if (_overrides instanceof SimpleMixInResolver) { + return ((SimpleMixInResolver) _overrides).hasMixIns(); + } + } + // cannot rule out the possibility, so... + return true; + } } |