What you'll want to use is a Filter - this will use only objects that match your conditions.
Position desiredPosition = new Position(1, 1, 1); //this definition should go right beneath your class definition
RS2Object rock = getObjects().closest(o -> o != null && o.getName().equals("Rocks") && o.getPosition().equals(desiredPosition));
//o represents the object. The conditions you'll want to check are that it is not null, it is in fact the correct type
//of RS2Object, and that it has the correct position (all shown in the filter above).
Note, this does not differentiate between different types of rocks.