Search in sources :

Example 1 with KeyValueRepresentation

use of org.nextprot.api.commons.utils.KeyValueRepresentation in project nextprot-api by calipho-sib.

the class InstrumentationAspect method addArgumentsParameters.

private static StringBuilder addArgumentsParameters(StringBuilder sb, Object[] arguments, Annotation[][] annotations) {
    for (int i = 0; i < arguments.length; i++) {
        Annotation[] annots = annotations[i];
        Value v = null;
        for (Annotation a : annots) {
            if (a.annotationType().equals(Value.class)) {
                v = (Value) a;
                break;
            }
        }
        if (v == null) {
            sb.append("arg" + (i + 1));
        } else {
            sb.append(v.value());
        }
        sb.append("=");
        Object argument = arguments[i];
        if (argument == null) {
            sb.append("null");
        } else if (argument instanceof KeyValueRepresentation) {
            sb.append(((KeyValueRepresentation) argument).toKeyValueString());
        } else if (argument instanceof Collection) {
            sb.append(((Collection<?>) argument).size());
        } else if (argument instanceof String || argument instanceof Long || argument instanceof Short || argument instanceof Integer) {
            sb.append(argument);
        } else {
            sb.append("representation-unknown");
        }
        sb.append(";");
    }
    return sb;
}
Also used : Value(org.springframework.beans.factory.annotation.Value) AtomicLong(java.util.concurrent.atomic.AtomicLong) Collection(java.util.Collection) KeyValueRepresentation(org.nextprot.api.commons.utils.KeyValueRepresentation) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Collection (java.util.Collection)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 KeyValueRepresentation (org.nextprot.api.commons.utils.KeyValueRepresentation)1 Value (org.springframework.beans.factory.annotation.Value)1