### Question:
PolygonHandler extends AbstractShapeHandler { protected List<List<LinearRing>> assignHolesToShells(final List<LinearRing> shells, final List<LinearRing> holes) { final int shellSize = shells.size(); final int holeSize = holes.size(); final List<List<LinearRing>> holesForShells = new ArrayList(shellSize); for (int i=0; i<shellSize ; i++) { holesForShells.add(new ArrayList<LinearRing>()); } for (final LinearRing testRing : holes) { final Envelope testEnv = testRing.getEnvelopeInternal(); final Coordinate testPt = testRing.getCoordinateN(0); LinearRing minShell = null; Envelope minEnv = null; for (final LinearRing tryRing : shells) { Envelope tryEnv = tryRing.getEnvelopeInternal(); if (minShell != null) { minEnv = minShell.getEnvelopeInternal(); } boolean isContained = false; final Coordinate[] coordList = tryRing.getCoordinates(); if (tryEnv.contains(testEnv) && (CGAlgorithms.isPointInRing(testPt, coordList) || (pointInList( testPt, coordList)))) { isContained = true; } if (isContained) { if ((minShell == null) || minEnv.contains(tryEnv)) { minShell = tryRing; } } } if (minShell == null) { shells.add(JTS.reverseRing(testRing)); holesForShells.add(new ArrayList()); } else { ((ArrayList) holesForShells.get(shells.indexOf(minShell))) .add(testRing); } } return holesForShells; } PolygonHandler(final boolean read3D);  PolygonHandler(final ShapeType type, final boolean read3D); @Override ShapeType getShapeType(); @Override int getLength(final Object geometry); @Override Geometry estimated(final double minX, final double maxX, final double minY, final double maxY); @Override Geometry read(final ByteBuffer buffer, final ShapeType type); @Override void write(final ByteBuffer buffer, final Object geometry);  }### Answer:
@Test public void testHoleAssignment() { java.awt.Dimension ps = new java.awt.Dimension(500, 500); PrecisionModel precision = new PrecisionModel(); ArrayList shells = new ArrayList(); ArrayList holes = new ArrayList(); int x = 10; int y = 10; shells.add(copyTo(x, y, ps.width - 2 * x, ps.height - 2 * y, rectangle( precision, 0))); int w = 11; int h = 11; int s = 10; int nx = (ps.width - 2 * x) / (w + s); int ny = (ps.height - 2 * y) / (h + s); for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { holes.add(copyTo(x + s + i * (w + s), y + s + j * (h + s), w, h, rectangle(precision, 0))); } } PolygonHandler ph = new PolygonHandler(true); List assigned = ph.assignHolesToShells(shells, holes); assertEquals(((ArrayList) assigned.get(0)).size(), holes.size()); }