### Question:
SimpleGridCell4D implements GridCell4D { @Override public boolean contains(GeoPosition position) { boolean hContains; boolean vContains; boolean tContains; if (position == null) { return false; } if (hGridCell == null) { if (position.getHorizontalPosition() != null) { return false; } else { hContains = true; } } else { if (position.getHorizontalPosition() == null) { return false; } else { hContains = hGridCell.contains(position.getHorizontalPosition()); } } if (vExtent == null) { if (position.getVerticalPosition() != null) { return false; } else { vContains = true; } } else { if (position.getVerticalPosition() == null) { return false; } else { if (!position.getVerticalPosition().getCoordinateReferenceSystem().equals(vCrs)) { return false; } vContains = vExtent.contains(position.getVerticalPosition().getZ()); } } if (tExtent == null) { if (position.getTime() != null) { return false; } else { tContains = true; } } else { if (position.getTime() == null) { return false; } else { tContains = tExtent.contains(position.getTime()); } } return hContains && vContains && tContains; } SimpleGridCell4D(GridCell2D hGridCell, Extent<Double> vExtent, VerticalCrs vCrs,
            Extent<DateTime> tExtent, Chronology chronology, GridDomain grid); @Override boolean contains(GeoPosition position); @Override HorizontalPosition getCentre(); @Override Polygon getFootprint(); @Override Extent<DateTime> getTimeExtent(); @Override Chronology getChronology(); @Override Extent<Double> getVerticalExtent(); @Override VerticalCrs getVerticalCrs(); @Override GridDomain getGrid();  }### Answer:
@Test public void testContains() { HorizontalPosition hPos = new HorizontalPosition(-6.5, 52.7, crs); VerticalPosition vPos = new VerticalPosition(100.9, depth); DateTime dt = new DateTime(2000, 1, 2, 12, 45, chronology); Array<GridCell2D> cells = sgd.getHorizontalGrid().getDomainObjects(); GridCell2D cell = cells.get(2, 3); SimpleGridCell4D sgc = new SimpleGridCell4D(cell, vExtent, depth, tExtent, chronology, sgd); GeoPosition gPos = new GeoPosition(hPos, vPos, dt); assertTrue(sgc.contains(gPos)); assertFalse(sgc.contains(null)); Chronology noleap = NoLeapChronology.getInstanceUTC(); dt = new DateTime(2000, 1, 2, 12, 45, noleap); gPos = new GeoPosition(hPos, vPos, dt); assertFalse(sgc.contains(gPos)); vPos = new VerticalPosition(1000.9, depth); dt = new DateTime(2000, 1, 2, 12, 45, chronology); gPos = new GeoPosition(hPos, vPos, dt); assertFalse(sgc.contains(gPos)); vPos = new VerticalPosition(800.9, depth); dt = new DateTime(2000, 11, 12, 2, 45, chronology); gPos = new GeoPosition(hPos, vPos, dt); assertFalse(sgc.contains(gPos)); hPos = new HorizontalPosition(-8.5, 53.7, crs); vPos = new VerticalPosition(100.9, depth); dt = new DateTime(2000, 1, 2, 12, 45, chronology); gPos = new GeoPosition(hPos, vPos, dt); assertFalse(sgc.contains(gPos)); cell = null; sgc = new SimpleGridCell4D(cell, vExtent, depth, tExtent, chronology, sgd); assertFalse(sgc.contains(gPos)); }