Class FieldAccessStrategy

  • All Implemented Interfaces:
    javax.json.bind.config.PropertyVisibilityStrategy

    public class FieldAccessStrategy
    extends java.lang.Object
    implements javax.json.bind.config.PropertyVisibilityStrategy

    Strategy that can be used to force always using fields instead of getters setters for getting / setting value.

    Suggested approach is to use default visibility strategy, which will use public getters / setters, or field if it is public.

    Please consider, that forcing accessing fields will in most cases (when field is not public) result in calling Field.setAccessible(boolean) to break into clients code. This may cause problems if client code is loaded as JPMS (Java Platform Module System) module, as OSGi module or when SecurityManager is turned on.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isVisible​(java.lang.reflect.Field field)  
      boolean isVisible​(java.lang.reflect.Method method)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FieldAccessStrategy

        public FieldAccessStrategy()
    • Method Detail

      • isVisible

        public boolean isVisible​(java.lang.reflect.Field field)
        Specified by:
        isVisible in interface javax.json.bind.config.PropertyVisibilityStrategy
      • isVisible

        public boolean isVisible​(java.lang.reflect.Method method)
        Specified by:
        isVisible in interface javax.json.bind.config.PropertyVisibilityStrategy