class GeometryTools {

    public static double getBondLengthAverage(IAtomContainer container) {
        double bondLengthSum = 0;
        Iterator<IBond> bonds = container.bonds().iterator();
        int bondCounter = 0;
        while (bonds.hasNext()) {
            IBond bond = bonds.next();
            IAtom atom1 = bond.getBegin();
            IAtom atom2 = bond.getEnd();
            if (atom1.getPoint2d() != null && atom2.getPoint2d() != null) {
                bondCounter++;
                bondLengthSum += getLength2D(bond);
            }
        }
        return bondLengthSum / bondCounter;
    }

}