method2testcases
stringlengths
118
6.63k
### Question: MultiGeometry implements Geometry { public List<Geometry> getGeometryObject() { return mGeometries; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }### Answer: @Test public...
### Question: LineString implements Geometry<List<LatLng>> { public String getGeometryType() { return GEOMETRY_TYPE; } LineString(List<LatLng> coordinates); String getGeometryType(); List<LatLng> getGeometryObject(); @Override String toString(); }### Answer: @Test public void testGetType() { LineString lineString = cr...
### Question: LineString implements Geometry<List<LatLng>> { public List<LatLng> getGeometryObject() { return mCoordinates; } LineString(List<LatLng> coordinates); String getGeometryType(); List<LatLng> getGeometryObject(); @Override String toString(); }### Answer: @Test public void testGetGeometryObject() { LineStrin...
### Question: GeoJsonPointStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonPointStyle(); @Override String[] getGeometryType(); float getAlpha(); void setAlpha(float alpha); float getAnchorU(); float getAnchorV(); void setAnchor(float anchorU, flo...
### Question: GeoJsonLayer extends Layer { public Iterable<GeoJsonFeature> getFeatures() { return (Iterable<GeoJsonFeature>) super.getFeatures(); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager ground...
### Question: GeoJsonLayer extends Layer { public void addFeature(GeoJsonFeature feature) { if (feature == null) { throw new IllegalArgumentException("Feature cannot be null"); } super.addFeature(feature); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, ...
### Question: GeoJsonLayer extends Layer { public void removeFeature(GeoJsonFeature feature) { if (feature == null) { throw new IllegalArgumentException("Feature cannot be null"); } super.removeFeature(feature); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonMan...
### Question: KmlTrack extends KmlLineString { public HashMap<String, String> getProperties() { return mProperties; } KmlTrack(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes, ArrayList<Long> timestamps, HashMap<String, String> properties); ArrayList<Long> getTimestamps(); HashMap<String, String> getProperti...
### Question: GeoJsonLayer extends Layer { public LatLngBounds getBoundingBox() { return mBoundingBox; } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager); GeoJsonLayer(GoogleMap ma...
### Question: GeoJsonLineStringStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonLineStringStyle(); @Override String[] getGeometryType(); int getColor(); void setColor(int color); boolean isClickable(); void setClickable(boolean clickable); boolea...
### Question: GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures...
### Question: GeoJsonParser { ArrayList<GeoJsonFeature> getFeatures() { return mGeoJsonFeatures; } GeoJsonParser(JSONObject geoJsonFile); static Geometry parseGeometry(JSONObject geoJsonGeometry); }### Answer: @Test public void testParseGeometryCollection() throws Exception { GeoJsonParser parser = new GeoJsonParser(v...
### Question: GeoJsonMultiLineString extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiLineString(List<GeoJsonLineString> geoJsonLineStrings); String getType(); List<GeoJsonLineString> getLineStrings(); }### Answer: @Test public void testGetType() { List<GeoJsonLineString> lineS...
### Question: GeoJsonMultiLineString extends MultiGeometry { public List<GeoJsonLineString> getLineStrings() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonLineString> geoJsonLineStrings = new ArrayList<GeoJsonLineString>(); for (Geometry geometry : geometryList) { GeoJsonLineString lineString = ...
### Question: GeoJsonFeature extends Feature implements Observer { public void setGeometry(Geometry geometry) { super.setGeometry(geometry); setChanged(); notifyObservers(); } GeoJsonFeature(Geometry geometry, String id, HashMap<String, String> properties, LatLngBounds boundingBox); String set...
### Question: GeoJsonFeature extends Feature implements Observer { public LatLngBounds getBoundingBox() { return mBoundingBox; } GeoJsonFeature(Geometry geometry, String id, HashMap<String, String> properties, LatLngBounds boundingBox); String setProperty(String property, String propertyValue)...
### Question: GeoJsonLineString extends LineString { public String getType() { return getGeometryType(); } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }### Answer: @Test ...
### Question: KmlMultiGeometry extends MultiGeometry { public ArrayList<Geometry> getGeometryObject() { List<Geometry> geometriesList = super.getGeometryObject(); return new ArrayList<>(geometriesList); } KmlMultiGeometry(ArrayList<Geometry> geometries); ArrayList<Geometry> getGeometryObject(); @Override String toStrin...
### Question: GeoJsonLineString extends LineString { public List<LatLng> getCoordinates() { return getGeometryObject(); } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }###...
### Question: GeoJsonLineString extends LineString { public List<Double> getAltitudes() { return mAltitudes; } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }### Answer: @T...
### Question: GeoJsonPoint extends Point { public String getType() { return getGeometryType(); } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }### Answer: @Test public void testGetType() { GeoJsonPoint p = new Geo...
### Question: GeoJsonPoint extends Point { public LatLng getCoordinates() { return getGeometryObject(); } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }### Answer: @Test public void testGetCoordinates() { GeoJsonP...
### Question: GeoJsonPoint extends Point { public Double getAltitude() { return mAltitude; } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }### Answer: @Test public void testGetAltitude() { GeoJsonPoint p = new Geo...
### Question: GeoJsonMultiPoint extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiPoint(List<GeoJsonPoint> geoJsonPoints); String getType(); List<GeoJsonPoint> getPoints(); }### Answer: @Test public void testGetType() { List<GeoJsonPoint> points = new ArrayList<>(); points.add(n...
### Question: GeoJsonMultiPoint extends MultiGeometry { public List<GeoJsonPoint> getPoints() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonPoint> geoJsonPoints = new ArrayList<GeoJsonPoint>(); for (Geometry geometry : geometryList) { GeoJsonPoint point = (GeoJsonPoint) geometry; geoJsonPoints.a...
### Question: GeoJsonPolygon implements DataPolygon { public String getType() { return GEOMETRY_TYPE; } GeoJsonPolygon( List<? extends List<LatLng>> coordinates); String getType(); List<? extends List<LatLng>> getCoordinates(); List<? extends List<LatLng>> getGeometryObject(); String getGeometryType(); Arra...
### Question: GeoJsonPolygon implements DataPolygon { public List<? extends List<LatLng>> getCoordinates() { return mCoordinates; } GeoJsonPolygon( List<? extends List<LatLng>> coordinates); String getType(); List<? extends List<LatLng>> getCoordinates(); List<? extends List<LatLng>> getGeometryObject(); St...
### Question: GeoJsonRenderer extends Renderer implements Observer { public void setMap(GoogleMap map) { super.setMap(map); for (Feature feature : super.getFeatures()) { redrawFeatureToMap((GeoJsonFeature) feature, map); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager markerMa...
### Question: KmlPoint extends Point { public Double getAltitude() { return mAltitude; } KmlPoint(LatLng coordinates); KmlPoint(LatLng coordinates, Double altitude); Double getAltitude(); }### Answer: @Test public void testPointAltitude() { KmlPoint kmlPoint = createSimplePoint(); assertNotNull(kmlPoint); assertNull(...
### Question: GeoJsonRenderer extends Renderer implements Observer { public void addFeature(GeoJsonFeature feature) { super.addFeature(feature); if (isLayerOnMap()) { feature.addObserver(this); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager markerManager, PolygonManager polyg...
### Question: GeoJsonRenderer extends Renderer implements Observer { public void removeLayerFromMap() { if (isLayerOnMap()) { for (Feature feature : super.getFeatures()) { removeFromMap(super.getAllFeatures().get(feature)); feature.deleteObserver(this); } setLayerVisibility(false); } } GeoJsonRenderer(GoogleMap map, Ha...
### Question: GeoJsonRenderer extends Renderer implements Observer { public void removeFeature(GeoJsonFeature feature) { super.removeFeature(feature); if (super.getFeatures().contains(feature)) { feature.deleteObserver(this); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager mar...
### Question: GeoJsonMultiPolygon extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiPolygon(List<GeoJsonPolygon> geoJsonPolygons); String getType(); List<GeoJsonPolygon> getPolygons(); }### Answer: @Test public void testGetType() { List<GeoJsonPolygon> polygons = new ArrayList<>...
### Question: GeoJsonMultiPolygon extends MultiGeometry { public List<GeoJsonPolygon> getPolygons() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonPolygon> geoJsonPolygon = new ArrayList<GeoJsonPolygon>(); for (Geometry geometry : geometryList) { GeoJsonPolygon polygon = (GeoJsonPolygon) geometry...
### Question: GeoJsonPolygonStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonPolygonStyle(); @Override String[] getGeometryType(); int getFillColor(); void setFillColor(int fillColor); boolean isGeodesic(); void setGeodesic(boolean geodesic); int...
### Question: Renderer { public GoogleMap getMap() { return mMap; } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManag...
### Question: Renderer { public Set<Feature> getFeatures() { return mFeatures.keySet(); } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, ...
### Question: Renderer { protected void addFeature(Feature feature) { Object mapObject = FEATURE_NOT_ON_MAP; if (feature instanceof GeoJsonFeature) { setFeatureDefaultStyles((GeoJsonFeature) feature); } if (mLayerOnMap) { if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.get(feature)); } if (feature.hasGeom...
### Question: Renderer { protected void removeFeature(Feature feature) { if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.remove(feature)); } } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, ...
### Question: KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public String getGeometryType() { return GEOMETRY_TYPE; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); List<List<LatLng>> getGeometryObject()...
### Question: Point implements Geometry { public String getGeometryType() { return GEOMETRY_TYPE; } Point(LatLng coordinates); String getGeometryType(); LatLng getGeometryObject(); @Override String toString(); }### Answer: @Test public void testGetGeometryType() { Point p = new Point(new LatLng(0, 50)); assertEquals("...
### Question: Point implements Geometry { public LatLng getGeometryObject() { return mCoordinates; } Point(LatLng coordinates); String getGeometryType(); LatLng getGeometryObject(); @Override String toString(); }### Answer: @Test public void testGetGeometryObject() { Point p = new Point(new LatLng(0, 50)); assertEqual...
### Question: Feature extends Observable { public String getId() { return mId; } Feature(Geometry featureGeometry, String id, Map<String, String> properties); Iterable<String> getPropertyKeys(); Iterable getProperties(); String getProperty(String property); String getId(); boolean hasProperty(String ...
### Question: Gradient { static int interpolateColor(int color1, int color2, float ratio) { int alpha = (int) ((Color.alpha(color2) - Color.alpha(color1)) * ratio + Color.alpha(color1)); float[] hsv1 = new float[3]; Color.RGBToHSV(Color.red(color1), Color.green(color1), Color.blue(color1), hsv1); float[] hsv2 = new flo...
### Question: Gradient { int[] generateColorMap(double opacity) { HashMap<Integer, ColorInterval> colorIntervals = generateColorIntervals(); int[] colorMap = new int[mColorMapSize]; ColorInterval interval = colorIntervals.get(0); int start = 0; for (int i = 0; i < mColorMapSize; i++) { if (colorIntervals.containsKey(i)...
### Question: PointQuadTree { public void clear() { mChildren = null; if (mItems != null) { mItems.clear(); } } PointQuadTree(double minX, double maxX, double minY, double maxY); PointQuadTree(Bounds bounds); private PointQuadTree(double minX, double maxX, double minY, double maxY, int depth); private PointQuadTree(...
### Question: PointQuadTree { public Collection<T> search(Bounds searchBounds) { final List<T> results = new ArrayList<T>(); search(searchBounds, results); return results; } PointQuadTree(double minX, double maxX, double minY, double maxY); PointQuadTree(Bounds bounds); private PointQuadTree(double minX, double maxX,...
### Question: SphericalUtil { static double computeAngleBetween(LatLng from, LatLng to) { return distanceRadians(toRadians(from.latitude), toRadians(from.longitude), toRadians(to.latitude), toRadians(to.longitude)); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeO...
### Question: SphericalUtil { public static double computeDistanceBetween(LatLng from, LatLng to) { return computeAngleBetween(from, to) * EARTH_RADIUS; } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static Lat...
### Question: SphericalUtil { public static double computeHeading(LatLng from, LatLng to) { double fromLat = toRadians(from.latitude); double fromLng = toRadians(from.longitude); double toLat = toRadians(to.latitude); double toLng = toRadians(to.longitude); double dLng = toLng - fromLng; double heading = atan2( sin(dLn...
### Question: KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<LatLng> getOuterBoundaryCoordinates() { return mOuterBoundaryCoordinates; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); List<Lis...
### Question: SphericalUtil { public static LatLng computeOffset(LatLng from, double distance, double heading) { distance /= EARTH_RADIUS; heading = toRadians(heading); double fromLat = toRadians(from.latitude); double fromLng = toRadians(from.longitude); double cosDistance = cos(distance); double sinDistance = sin(dis...
### Question: SphericalUtil { public static LatLng computeOffsetOrigin(LatLng to, double distance, double heading) { heading = toRadians(heading); distance /= EARTH_RADIUS; double n1 = cos(distance); double n2 = sin(distance) * cos(heading); double n3 = sin(distance) * sin(heading); double n4 = sin(toRadians(to.latitud...
### Question: SphericalUtil { public static double computeLength(List<LatLng> path) { if (path.size() < 2) { return 0; } double length = 0; LatLng prev = path.get(0); double prevLat = toRadians(prev.latitude); double prevLng = toRadians(prev.longitude); for (LatLng point : path) { double lat = toRadians(point.latitude)...
### Question: SphericalUtil { public static double computeArea(List<LatLng> path) { return abs(computeSignedArea(path)); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static LatLng computeOffsetOrigin(LatLng t...
### Question: SphericalUtil { public static double computeSignedArea(List<LatLng> path) { return computeSignedArea(path, EARTH_RADIUS); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static LatLng computeOffset...
### Question: PolyUtil { public static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic) { return containsLocation(point.latitude, point.longitude, polygon, geodesic); } private PolyUtil(); static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic); static boolea...
### Question: PolyUtil { public static boolean isClosedPolygon(List<LatLng> poly) { LatLng firstPoint = poly.get(0); LatLng lastPoint = poly.get(poly.size() - 1); return firstPoint.equals(lastPoint); } private PolyUtil(); static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic); static boo...
### Question: KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<List<LatLng>> getInnerBoundaryCoordinates() { return mInnerBoundaryCoordinates; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); Li...
### Question: PolyUtil { public static List<LatLng> decode(final String encodedPath) { int len = encodedPath.length(); final List<LatLng> path = new ArrayList<LatLng>(); int index = 0; int lat = 0; int lng = 0; while (index < len) { int result = 1; int shift = 0; int b; do { b = encodedPath.charAt(index++) - 63 - 1; re...
### Question: KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<List<LatLng>> getGeometryObject() { List<List<LatLng>> coordinates = new ArrayList<>(); coordinates.add(mOuterBoundaryCoordinates); if (mInnerBoundaryCoordinates != null) { coordinates.addAll(mInnerBoundaryCoordinates); } return...
### Question: ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void setFirst(@Nonnull ExternalTaskExecutionInfo task) { insertElementAt(task, 0); for (int i = 1; i < size(); i++) { if (task.equals(getElementAt(i))) { remove(i); break; } } ensureSize(ExternalSystemConsta...
### Question: ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmpty...
### Question: VcsLogMultiRepoJoiner { @Nonnull public List<Commit> join(@Nonnull Collection<List<Commit>> logsFromRepos) { if (logsFromRepos.size() == 1) { return logsFromRepos.iterator().next(); } int size = 0; for (List<Commit> repo : logsFromRepos) { size += repo.size(); } List<Commit> result = new ArrayList<>(size)...
### Question: DefaultArrangementEntryMatcherSerializer { @SuppressWarnings("MethodMayBeStatic") @javax.annotation.Nullable public <T extends ArrangementEntryMatcher> Element serialize(@Nonnull T matcher) { if (matcher instanceof StdArrangementEntryMatcher) { return serialize(((StdArrangementEntryMatcher)matcher).getCon...
### Question: RxDownloader { public Single<List<FileContainer>> asList() { this.subject.subscribe(this.itemsObserver); this.size = this.files.size(); this.remains = this.size; Observable<FileContainer> observable = Observable .fromIterable(this.files) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.i...
### Question: Utils { public static void shouldAllPositive(int... numbers) { for (int num : numbers) { if (num < 1) { throw new IllegalArgumentException("Number should be > 0"); } } } static int toPositiveInt(String input); static void shouldAllPositive(int... numbers); static void shouldAllNonNegative(int... numbers)...
### Question: CommandFactory { public Command getCommand(String commandLine) throws InvalidCommandException, InvalidCommandParams { commandLine = commandLine.trim().replaceAll(" {2}", " "); String[] split = commandLine.split(" "); String mainCommand = split[0].toUpperCase(); String[] params = Arrays.copyOfRange(split, ...
### Question: EntityFactory { public Entity getEntity(DrawEntityCommand command) { if (command instanceof DrawLineCommand) { DrawLineCommand cmd = (DrawLineCommand) command; return new Line(cmd.getX1(), cmd.getY1(), cmd.getX2(), cmd.getY2()); } else if (command instanceof DrawRectangleCommand) { DrawRectangleCommand cm...
### Question: IEXByteConverter { public static short convertBytesToShort(final byte[] bytes) { return (short) ( (0xff & bytes[1]) << 8 | (0xff & bytes[0]) << 0); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesTo...
### Question: IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public int hashCode() { return Objects.hashCode(number); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int hashCo...
### Question: IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public int compareTo(final IEXPrice iexPrice) { return compare(this.getNumber(), iexPrice.getNumber()); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override...
### Question: IEXTOPSMessageBlock extends IEXSegment { public static IEXSegment createIEXSegment(final byte[] packet) { final List<IEXMessage> iexMessages = new ArrayList<>(); int offset = 40; final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset)); for (...
### Question: IEXByteConverter { public static int convertBytesToUnsignedShort(final byte[] bytes) { return convertBytesToShort(bytes) & 0xffff; } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(fin...
### Question: IEXByteConverter { public static int convertBytesToInt(final byte[] bytes) { return ((0xff & bytes[3]) << 24 | (0xff & bytes[2]) << 16 | (0xff & bytes[1]) << 8 | (0xff & bytes[0]) << 0 ); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final ...
### Question: IEXByteConverter { public static long convertBytesToLong(final byte[] bytes) { return (long) (0xff & bytes[7]) << 56 | (long) (0xff & bytes[6]) << 48 | (long) (0xff & bytes[5]) << 40 | (long) (0xff & bytes[4]) << 32 | (long) (0xff & bytes[3]) << 24 | (long) (0xff & bytes[2]) << 16 | (long) (0xff & bytes[1...
### Question: IEXByteConverter { public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) { return new IEXPrice(convertBytesToLong(bytes)); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort...
### Question: IEXByteConverter { public static String convertBytesToString(final byte[] bytes) { return new String(bytes).trim(); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(final byte[] bytes...
### Question: IEXSegment { @Override public int hashCode() { return Objects.hash(messageHeader, messages); } protected IEXSegment( final IEXMessageHeader messageHeader, final List<IEXMessage> messages); IEXMessageHeader getMessageHeader(); List<IEXMessage> getMessages(); @Override boolean equal...
### Question: IEXMessageHeader { @Override public int hashCode() { return Objects.hash(version, messageProtocolID, channelID, sessionID, payloadLength, messageCount, streamOffset, firstMessageSequenceNumber, sendTime); } private IEXMessageHeader( final byte version, final IEXMessageProtocol mes...
### Question: IEXPrice implements Comparable<IEXPrice>, Serializable { public long getNumber() { return number; } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int hashCode(); @Override String toS...
### Question: IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public String toString() { return toBigDecimal() .toString(); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int h...
### Question: BookServiceImpl implements BookService { @Override @Transactional public Book saveBook(@NotNull @Valid final Book book) { LOGGER.debug("Creating {}", book); Book existing = repository.findOne(book.getId()); if (existing != null) { throw new BookAlreadyExistsException( String.format("There already exists a...
### Question: BookServiceImpl implements BookService { @Override @Transactional(readOnly = true) public List<Book> getList() { LOGGER.debug("Retrieving the list of all users"); return repository.findAll(); } @Autowired BookServiceImpl(final BookRepository repository); @Override @Transactional Book saveBook(@NotNull @V...
### Question: BookController { @RequestMapping(value = "/books", method = RequestMethod.POST, consumes = {"application/json"}) public Book saveBook(@RequestBody @Valid final Book book) { LOGGER.debug("Received request to create the {}", book); return bookService.saveBook(book); } @Autowired BookController(final BookSe...
### Question: BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); }...
### Question: MockableClient extends OkHttpClient { @Override public Call newCall(Request request) { if (shouldMockRequest(request)) { return mockedClient.newCall(request); } else { return realClient.newCall(request); } } MockableClient(Registry registry, OkHttpClient realClient, R...
### Question: ReplaceEndpointClient extends OkHttpClient { @Override public Call newCall(Request request) { return realClient.newCall( withReplacedEndpoint(request) ); } ReplaceEndpointClient(String newEndpoint, OkHttpClient realClient); @Override Call newCall(Request request); }### Answer: @...
### Question: Registry { public boolean isInRegistry(String url) { if (getMockedEndpointsMethod == null) { return false; } Set<String> mockedEndpoints = getMockedEndpoints(); for (String endpoint : mockedEndpoints) { if (endpointMatches(endpoint, url)) { return true; } } return false; } Registry(); boolean isInRegistry...
### Question: IEXOrderBook implements OrderBook { public void priceLevelUpdate(final IEXPriceLevelUpdateMessage iexPriceLevelUpdateMessage) { switch (iexPriceLevelUpdateMessage.getIexMessageType()) { case PRICE_LEVEL_UPDATE_SELL: askSide.priceLevelUpdate(iexPriceLevelUpdateMessage); break; case PRICE_LEVEL_UPDATE_BUY: ...
### Question: PriceLevel { @Override public int hashCode() { return Objects.hash(symbol, timestamp, price, size); } PriceLevel( final String symbol, final long timestamp, final IEXPrice price, final int size); String getSymbol(); long getTimestamp(); IEXPrice getPrice(); ...
### Question: IMemoryImageInputStream extends ImageInputStreamImpl { @Override public long getStreamPosition() throws IOException { return address; } IMemoryImageInputStream(IMemory memory, long startingAddress); @Override int read(byte[] buffer, int offset, int length); @Override int read(); @Override long getStreamPo...
### Question: IMemoryImageInputStream extends ImageInputStreamImpl { @Override public void seek(long pos) throws IOException { address = pos; } IMemoryImageInputStream(IMemory memory, long startingAddress); @Override int read(byte[] buffer, int offset, int length); @Override int read(); @Override long getStreamPosition...
### Question: Addresses { public static boolean greaterThan(long a, long b) { if (signBitsSame(a, b)) { return a > b; } else { return a < b; } } static boolean greaterThan(long a, long b); static boolean greaterThanOrEqual(long a, long b); static boolean lessThan(long a, long b); static boolean lessThanOrEqual(long a,...
### Question: Addresses { public static boolean lessThan(long a, long b) { if (signBitsSame(a, b)) { return a < b; } else { return a > b; } } static boolean greaterThan(long a, long b); static boolean greaterThanOrEqual(long a, long b); static boolean lessThan(long a, long b); static boolean lessThanOrEqual(long a, lo...
### Question: SqlBuilder { public String build() { addCopyTable(); addColumnNames(); addFileConfig(); return getSql(); } SqlBuilder(EntityInfo entityInfo); String build(); void addCopyTable(); void addColumnNames(); void addFileConfig(); String getSql(); }### Answer: @Test public void testCompleteQuery() { SqlBuilder ...
### Question: LoadDataEscaper { public String escapeForLoadFile(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.lengt...
### Question: PgCopyEscaper { public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength = text.length(); ...
### Question: SqlBuilder { public String build() { addLoadDataIntoTable(); addFileConfig(); addColumnNames(); return getSql(); } SqlBuilder(EntityInfo entityInfo); String build(); void addLoadDataIntoTable(); void addFileConfig(); void addColumnNames(); String getSql(); }### Answer: @Test public void testCompleteQuery...
### Question: UriUtils { public static URI getParent(final URI uri) { if (isRoot(uri)) { return null; } else { final URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve("."); final String parentStr = parent.toString(); return isRoot(parent) ? parent : URI.create(parentStr.substring(0, parentStr.l...