private void setProperty()

in log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/LogEventFactory.java [323:359]


		private void setProperty(Method method, Object[] objects) {
			String name = NamingUtils.lowerFirst(NamingUtils.getMethodShortName(method.getName()));
			if (objects == null || objects[0] == null) {
				throw new IllegalArgumentException("No value to be set for " + name);
			}

			StringBuilder errors = new StringBuilder();
			Annotation[] annotations = method.getDeclaredAnnotations();
			for (Annotation annotation : annotations) {
				if (annotation instanceof Constraints) {
					Constraints constraints = (Constraints) annotation;
					validateConstraints(false, constraints.value(), name, objects[0].toString(),
							errors);
				} else if (annotation instanceof Constraint) {
					Constraint constraint = (Constraint) annotation;
					constraintPlugins.validateConstraint(false, constraint.constraintType(),
							name, objects[0].toString(), constraint.constraintValue(), errors);
				}
			}
			if (errors.length() > 0) {
				throw new ConstraintValidationException(errors.toString());
			}

			String result;
			if (objects[0] instanceof List) {
				result = StringUtils.join(objects, ", ");
			} else if (objects[0] instanceof Map) {
				StructuredDataMessage extra = new StructuredDataMessage(name, null, null);
				extra.putAll((Map) objects[0]);
				msg.addContent(name, extra);
				return;
			} else {
				result = objects[0].toString();
			}

			msg.put(name, result);
		}