code: public void serialize( JsonWriter writer, T value, JsonSerializationContext ctx, JsonSerializerParameters params, boolean isMapValue ) throws
              JsonSerializationException {
          if ( null != params.getInclude() ) {
              switch ( params.getInclude() ) {
                  case ALWAYS:
                      if ( null == value ) {
                          serializeNullValue( writer, ctx, params );
                      } else {
                          doSerialize( writer, value, ctx, params );
                      }
                      return;
                  case NON_DEFAULT:
                      if ( isDefault( value ) && !isMapValue ) {
                          writer.cancelName();
                      } else {
                          doSerialize( writer, value, ctx, params );
                      }
                      return;
                  case NON_EMPTY:
                      if ( isEmpty( value ) && !isMapValue ) {
                          writer.cancelName();
                      } else {
                          doSerialize( writer, value, ctx, params );
                      }
                      return;
                  case NON_NULL:
                      if ( null == value && !isMapValue) {
                          writer.cancelName();
                      } else {
                          doSerialize( writer, value, ctx, params );
                      }
                      return;
                  case NON_ABSENT:
                      if ( isAbsent( value ) && !isMapValue) {
                          writer.cancelName();
                      } else {
                          doSerialize( writer, value, ctx, params );
                      }
                      return;
              }
          }
  
          if ( null == value ) {
              if ( ctx.isSerializeNulls() || ( isMapValue && ctx.isWriteNullMapValues() ) ) {
                  serializeNullValue( writer, ctx, params );
              } else {
                  writer.cancelName();
              }
          } else {
              doSerialize( writer, value, ctx, params );
          }
      }
docs: Serializes an object into JSON output.
  
  @param writer {@link JsonWriter} used to write the serialized JSON
  @param value Object to serialize
  @param ctx Context for the full serialization process
  @param params Parameters for this serialization
  @param isMapValue indicate if you're serializing a Map value
  @throws JsonSerializationException if an error occurs during the serialization