1 package com.fasterxml.jackson.annotation; 2 3 /** 4 * Enumeration used to define kinds of elements (called "property accessors") 5 * that annotations like {@link JsonAutoDetect} apply to. 6 *<p> 7 * In addition to method types (GETTER/IS_GETTER, SETTER, CREATOR) and the 8 * field type (FIELD), 2 pseudo-types 9 * are defined for convenience: <code>ALWAYS</code> and <code>NONE</code>. These 10 * can be used to indicate, all or none of available method types (respectively), 11 * for use by annotations that takes <code>JsonMethod</code> argument. 12 */ 13 public enum PropertyAccessor 14 { 15 /** 16 * Getters are methods used to get a POJO field value for serialization, 17 * or, under certain conditions also for de-serialization. Latter 18 * can be used for effectively setting Collection or Map values 19 * in absence of setters, iff returned value is not a copy but 20 * actual value of the logical property. 21 *<p> 22 * Since version 1.3, this does <b>NOT</b> include "is getters" (methods 23 * that return boolean and named 'isXxx' for property 'xxx'); instead, 24 * {@link #IS_GETTER} is used}. 25 */ 26 GETTER, 27 28 /** 29 * Setters are methods used to set a POJO value for deserialization. 30 */ 31 SETTER, 32 33 /** 34 * Creators are constructors and (static) factory methods used to 35 * construct POJO instances for deserialization 36 */ 37 CREATOR, 38 39 /** 40 * Field refers to fields of regular Java objects. Although 41 * they are not really methods, addition of optional field-discovery 42 * in version 1.1 meant that there was need to enable/disable 43 * their auto-detection, and this is the place to add it in. 44 */ 45 FIELD, 46 47 /** 48 * "Is getters" are getter-like methods that are named "isXxx" 49 * (instead of "getXxx" for getters) and return boolean value 50 * (either primitive, or {@link java.lang.Boolean}). 51 * 52 */ 53 IS_GETTER, 54 55 /** 56 * This pseudo-type indicates that none of accessors if affected. 57 */ 58 NONE, 59 60 /** 61 * This pseudo-type indicates that all accessors are affected. 62 */ 63 ALL 64 ; 65 PropertyAccessor()66 private PropertyAccessor() { } 67 creatorEnabled()68 public boolean creatorEnabled() { 69 return (this == CREATOR) || (this == ALL); 70 } 71 getterEnabled()72 public boolean getterEnabled() { 73 return (this == GETTER) || (this == ALL); 74 } 75 isGetterEnabled()76 public boolean isGetterEnabled() { 77 return (this == IS_GETTER) || (this == ALL); 78 } 79 setterEnabled()80 public boolean setterEnabled() { 81 return (this == SETTER) || (this == ALL); 82 } 83 fieldEnabled()84 public boolean fieldEnabled() { 85 return (this == FIELD) || (this == ALL); 86 } 87 } 88