@SuppressWarnings("unchecked")
 private void useLoggingInfoInsertValue(
     LoggingInfo loggingInfo, Object target, Annotation annotation, Method method) {
   if (annotation instanceof UseLoggingInfoConvertor) {
     UseLoggingInfoConvertor useLoggingInfo = (UseLoggingInfoConvertor) annotation;
     boolean f = false;
     for (PublisherType publisherType : useLoggingInfo.publisherTypes()) {
       if (publisherType.equals(loggingInfo.getPublisherType())) {
         f = true;
         break;
       }
     }
     if (f) {
       Class<? extends LoggingInfoConvertor<?>> convertorClass = useLoggingInfo.convertor();
       LoggingInfoConvertor<Object> convertor = null;
       try {
         convertor = (LoggingInfoConvertor<Object>) convertorClass.newInstance();
       } catch (Exception e) {
         if (log.isErrorEnabled()) {
           log.error("LoggingInfo convertor instantiation was failed!", e);
         }
         return;
       }
       if (convertor != null) {
         Object convertedValue = null;
         try {
           convertedValue = convertor.convert(loggingInfo);
         } catch (Exception e) {
           if (log.isErrorEnabled()) {
             log.error(
                 "LoggingInfo convertation was failed! Null value used as convertation result!",
                 e);
           }
           convertedValue = null;
         }
         try {
           method.invoke(target, convertedValue);
         } catch (Exception e) {
           if (log.isErrorEnabled()) {
             log.error(
                 "Method invoke was failed! Please, check that method '"
                     + method.toGenericString()
                     + "' annotated correctly!",
                 e);
           }
         }
       }
     }
   }
 }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(LoggingInfo loggingInfo, StructuredJsonGenerator jsonGenerator) {

    if (loggingInfo == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (loggingInfo.getS3BucketName() != null) {
        jsonGenerator.writeFieldName("S3BucketName").writeValue(loggingInfo.getS3BucketName());
      }
      if (loggingInfo.getS3KeyPrefix() != null) {
        jsonGenerator.writeFieldName("S3KeyPrefix").writeValue(loggingInfo.getS3KeyPrefix());
      }
      if (loggingInfo.getS3Region() != null) {
        jsonGenerator.writeFieldName("S3Region").writeValue(loggingInfo.getS3Region());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public void map(LoggingInfo loggingInfo, Object target) {
    LoggingCustomData loggingCustomData = loggingInfo.getLoggingCustomData();
    Class<?> targetClass = target.getClass();
    Class<?> klass = targetClass;
    Map<Annotation, Method> customAnnotationMethodMap = new HashMap<Annotation, Method>();
    Map<Annotation, Method> annotationMethodMap = new HashMap<Annotation, Method>();
    while (klass != Object.class) {
      for (final Method method : klass.getDeclaredMethods()) {
        for (final Annotation annotation : method.getAnnotations()) {
          if (loggingCustomData != null
              && CUSTOM_ANNOTATIONS.contains(annotation.annotationType())) {
            if (method.getParameterTypes().length != 1) {
              if (log.isWarnEnabled()) {
                log.warn(
                    "Please, check that annotated method '"
                        + method.toGenericString()
                        + "' is setter method!");
              }
            }
            customAnnotationMethodMap.put(annotation, method);
          }
          if (MAPPING_ANNOTATIONS.contains(annotation.annotationType())) {
            if (method.getParameterTypes().length != 1) {
              if (log.isWarnEnabled()) {
                log.warn(
                    "Please, check that annotated method '"
                        + method.toGenericString()
                        + "' is setter method!");
              }
            }
            annotationMethodMap.put(annotation, method);
          }
        }
      }
      klass = klass.getSuperclass();
    }

    for (Entry<Annotation, Method> entry : annotationMethodMap.entrySet()) {
      Annotation annotation = entry.getKey();
      Method method = entry.getValue();
      if (SetterIncomingTime.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingInfo.getIncomingMessageTime());
      }
      if (SetterOutcomingTime.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingInfo.getOutcomingMessageTime());
      }
      if (SetterInputName.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingInfo.getInputName());
      }
      if (SetterServiceName.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingInfo.getServiceName());
      }
      if (SetterPublisher.class.equals(annotation.annotationType())) {
        insertValue(
            loggingInfo, target, annotation, method, loggingInfo.getPublisherType().toString());
      }
      if (loggingInfo.getRequestMessage() != null) {
        if (SetterUrl.class.equals(annotation.annotationType())
            && loggingInfo.getRequestMessage().getAddress() != null) {
          insertValue(
              loggingInfo,
              target,
              annotation,
              method,
              loggingInfo.getRequestMessage().getAddress().toString());
        }
        if (SetterRequest.class.equals(annotation.annotationType())
            && loggingInfo.getResponseMessage().getPayload() != null) {
          insertValue(
              loggingInfo,
              target,
              annotation,
              method,
              loggingInfo.getRequestMessage().getPayload().toString());
        }
      } else {
        log.error("Request message is not present!");
      }
      if (loggingInfo.getResponseMessage() != null) {
        if (SetterResponse.class.equals(annotation.annotationType())
            && loggingInfo.getResponseMessage().getPayload() != null) {
          insertValue(
              loggingInfo,
              target,
              annotation,
              method,
              loggingInfo.getResponseMessage().getPayload().toString());
        }
      } else {
        log.error("Response message is not present!");
      }
      if (UseLoggingInfoConvertor.class.equals(annotation.annotationType())) {
        useLoggingInfoInsertValue(loggingInfo, target, annotation, method);
      }
    }

    for (Entry<Annotation, Method> entry : customAnnotationMethodMap.entrySet()) {
      Annotation annotation = entry.getKey();
      Method method = entry.getValue();
      if (SetterCustomStringValue1.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue1());
      }
      if (SetterCustomStringValue2.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue2());
      }
      if (SetterCustomStringValue3.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue3());
      }
      if (SetterCustomStringValue4.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue4());
      }
      if (SetterCustomStringValue5.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue5());
      }

      if (SetterCustomNumberValue1.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue1());
      }
      if (SetterCustomNumberValue2.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue2());
      }
      if (SetterCustomNumberValue3.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue3());
      }
      if (SetterCustomNumberValue4.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue4());
      }
      if (SetterCustomNumberValue5.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue5());
      }

      if (SetterCustomDateValue1.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue1());
      }
      if (SetterCustomDateValue2.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue2());
      }
      if (SetterCustomDateValue3.class.equals(annotation.annotationType())) {
        insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue3());
      }
    }
  }
 @SuppressWarnings("unchecked")
 private void insertValue(
     LoggingInfo loggingInfo, Object target, Annotation annotation, Method method, Object value) {
   boolean f = false;
   try {
     Method publisherTypeMethod =
         annotation.annotationType().getMethod("publisherTypes", new Class<?>[] {});
     PublisherType[] publisherTypes = (PublisherType[]) publisherTypeMethod.invoke(annotation);
     for (PublisherType publisherType : publisherTypes) {
       if (publisherType.equals(loggingInfo.getPublisherType())) {
         f = true;
         break;
       }
     }
   } catch (Exception e) {
     f = false;
     if (log.isErrorEnabled()) {
       log.error("Invalid annotation!", e);
     }
   }
   if (f) {
     Class<? extends TypeConvertor<?, ?>> typeConvertorClass = null;
     try {
       Method convertorMethod =
           annotation.annotationType().getMethod("convertor", new Class<?>[] {});
       typeConvertorClass =
           (Class<? extends TypeConvertor<?, ?>>) convertorMethod.invoke(annotation);
     } catch (Exception e) {
       if (log.isErrorEnabled()) {
         log.error("Invalid annotation!", e);
       }
       return;
     }
     if (!(DefaultTypeConvertor.class.equals(typeConvertorClass)
         || DefaultStringConvertor.class.equals(typeConvertorClass)
         || DefaultNumberConvertor.class.equals(typeConvertorClass)
         || DefaultDateConvertor.class.equals(typeConvertorClass))) {
       TypeConvertor<Object, Object> convertor = null;
       try {
         convertor = (TypeConvertor<Object, Object>) typeConvertorClass.newInstance();
       } catch (Exception e) {
         if (log.isErrorEnabled()) {
           log.error(
               "Type convertor instantiation was failed! Null value used as result value!", e);
         }
         value = null;
       }
       if (convertor != null) {
         try {
           value = convertor.convert(value);
         } catch (Exception e) {
           if (log.isErrorEnabled()) {
             log.error("Type convertation was failed! Null value used as result value!", e);
           }
           value = null;
         }
       }
     }
     try {
       method.invoke(target, value);
     } catch (Exception e) {
       if (log.isErrorEnabled()) {
         log.error("Method invoke was failed! Please, check that method annotated correctly!", e);
       }
     }
   }
 }