package jcgp.function; import jcgp.population.Connection; public class Addition extends Function { private int arity = 2; @Override public Object run(Connection... connections) { if (connections.length < arity) { throw new InvalidArgumentsException("Not enough connections were given."); } else if (connections[0].getValue() instanceof Integer) { return ((Integer) connections[0].getValue()) + ((Integer) connections[1].getValue()); } else { throw new InvalidArgumentsException("Wrong data type, this function takes Integer."); } } @Override public int getArity() { return arity; } }