All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.novatec.testit.livingdoc.reflect.InvocationMessage Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package info.novatec.testit.livingdoc.reflect;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;


public class InvocationMessage extends Message {

    private final List messages = new ArrayList();

    public void addMessage(Message message) {
        messages.add(message);
    }

    @Override
    public int getArity() {
        if (messages.isEmpty()) {
            return 0;
        }

        return messages.get(0).getArity();
    }

    public boolean isEmpty() {
        return messages.isEmpty();
    }

    @Override
    public Object send(String... args) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException,
        SystemUnderDevelopmentException {
        for (Message message : messages) {
            if (message.getArity() == args.length) {
                return message.send(args);
            }
        }
        throw new IllegalArgumentException(String.format("No such method with %d arguments", args.length));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy