auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public String identifyMainMode( final List<? extends PlanElement> tripElements) { String mode = ((Leg) tripElements.get( 0 )).getMode(); if ( mode.equals( TransportMode.transit_walk ) ) { return TransportMode.pt ; } if ( mode.endsWith( "_fallback" ) ) { return mode.split( "_fallback" )[0] ; } for ( PlanElement pe : tripElements ) { if ( pe instanceof Leg ) { Leg leg = (Leg) pe ; String mode2 = leg.getMode() ; if ( !mode2.contains( TransportMode.non_network_walk ) && !mode2.contains( TransportMode.non_network_walk ) && !mode2.contains( TransportMode.transit_walk ) ) { return mode2 ; } } } throw new RuntimeException( "could not identify main mode "+ tripElements) ; }

Target:
public String identifyMainMode( final List<? extends PlanElement> tripElements) { String mode = ((Leg) tripElements.get( 0 )).getMode(); if ( mode.equals( TransportMode.transit_walk ) ) { return TransportMode.pt ; } if ( mode.endsWith( "_fallback" ) ) { return mode.substring(0, mode.length() - 9) ; } for ( PlanElement pe : tripElements ) { if ( pe instanceof Leg ) { Leg leg = (Leg) pe ; String mode2 = leg.getMode() ; if ( !mode2.contains( TransportMode.non_network_walk ) && !mode2.contains( TransportMode.non_network_walk ) && !mode2.contains( TransportMode.transit_walk ) ) { return mode2 ; } } } throw new RuntimeException( "could not identify main mode "+ tripElements) ; }
Source:
private AbstractMap.SimpleEntry<String, Boolean> cookieDomain(String cookieDomain, String requestDomain) { if (cookieDomain != null) { if (!cookieDomain.isEmpty() && cookieDomain.charAt(0) == '.') return new AbstractMap.SimpleEntry<>(cookieDomain.substring(1).toLowerCase(), false); else return new AbstractMap.SimpleEntry<>(cookieDomain.toLowerCase(), false); } else return new AbstractMap.SimpleEntry<>(requestDomain, true); }

Target:
private AbstractMap.SimpleEntry<String, Boolean> cookieDomain(String cookieDomain, String requestDomain) { if (cookieDomain != null) { String normalizedCookieDomain = cookieDomain.toLowerCase(); return new AbstractMap.SimpleEntry<>( (!cookieDomain.isEmpty() && cookieDomain.charAt(0) == '.') ? normalizedCookieDomain.substring(1) : normalizedCookieDomain, false); } else return new AbstractMap.SimpleEntry<>(requestDomain, true); }
Source:
private void change(SyncInfo[] collected) { Subscriber subscriber = getSubscriber(); for (SyncInfo c : collected) { try { SyncInfo info = c; SyncInfo newInfo = subscriber.getSyncInfo(info.getLocal()); if (newInfo == null || !newInfo.equals(info)) { remove(info); } }catch (TeamException e) { CVSUIPlugin.log(e); } } }

Target:
private void change(SyncInfo[] collected) { Subscriber subscriber = getSubscriber(); for (SyncInfo info : collected) { try { SyncInfo newInfo = subscriber.getSyncInfo(info.getLocal()); if (newInfo == null || !newInfo.equals(info)) { remove(info); } } catch (TeamException e) { CVSUIPlugin.log(e); } } }
Source:
public void testCreate() throws StripeException { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("attr1", "val1"); attributes.put("attr2", "val2"); Map<String, Object> inventory = new HashMap<String, Object>(); inventory.put("type", "bucket"); inventory.put("value", "limited"); Map<String, Object> params = new HashMap<String, Object>(); params.put("active", true); params.put("attributes", attributes); params.put("price", 499); params.put("currency", "usd"); params.put("inventory", inventory); params.put("product", "prod_123"); params.put("image", "<LINK_0>"); SKU sku = SKU.create(params); assertNotNull(sku); verifyRequest( APIResource.RequestMethod.POST, "/v1/skus", params ); }

Target:
public void testCreate() throws StripeException { final Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("attr1", "val1"); attributes.put("attr2", "val2"); final Map<String, Object> inventory = new HashMap<String, Object>(); inventory.put("type", "bucket"); inventory.put("value", "limited"); final Map<String, Object> params = new HashMap<String, Object>(); params.put("active", true); params.put("attributes", attributes); params.put("price", 499); params.put("currency", "usd"); params.put("inventory", inventory); params.put("product", "prod_123"); params.put("image", "<LINK_0>"); final SKU sku = SKU.create(params); assertNotNull(sku); verifyRequest( APIResource.RequestMethod.POST, "/v1/skus", params ); }
Source:
public List<QueryResult<CohortAclEntry>> getAcl(String studyStr, List<String> cohortList, String member, boolean silent, String sessionId) throws CatalogException { ParamUtils.checkObj(member, "member"); MyResourceIds resource = getIds(cohortList, studyStr, sessionId); checkMembers(resource.getStudyId(), Arrays.asList(member)); List<QueryResult<CohortAclEntry>> cohortAclList = new ArrayList<>(resource.getResourceIds().size()); for (Long cohortId : resource.getResourceIds()) { try { QueryResult<CohortAclEntry> allCohortAcls = authorizationManager.getCohortAcl(resource.getStudyId(), cohortId, resource.getUser(), member); allCohortAcls.setId(String.valueOf(cohortId)); cohortAclList.add(allCohortAcls); } catch (CatalogException e) { if (silent) { cohortAclList.add(new QueryResult<>(studyStr, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return cohortAclList; }

Target:
public List<QueryResult<CohortAclEntry>> getAcl(String studyStr, List<String> cohortList, String member, boolean silent, String sessionId) throws CatalogException { ParamUtils.checkObj(member, "member"); MyResourceIds resource = getIds(cohortList, studyStr, sessionId); checkMembers(resource.getStudyId(), Arrays.asList(member)); List<QueryResult<CohortAclEntry>> cohortAclList = new ArrayList<>(resource.getResourceIds().size()); List<Long> resourceIds = resource.getResourceIds(); for (int i = 0; i < resourceIds.size(); i++) { Long cohortId = resourceIds.get(i); try { QueryResult<CohortAclEntry> allCohortAcls = authorizationManager.getCohortAcl(resource.getStudyId(), cohortId, resource.getUser(), member); allCohortAcls.setId(String.valueOf(cohortId)); cohortAclList.add(allCohortAcls); } catch (CatalogException e) { if (silent) { cohortAclList.add(new QueryResult<>(cohortList.get(i), 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return cohortAclList; }
Source:
public StoredBlock get(Sha256Hash hash) throws BlockStoreException { lock.lock(); final MappedByteBuffer buffer = this.buffer; if (buffer == null) throw new BlockStoreException("Store closed"); ChainMap map = chainMaps.get(hash); if (map == null) return null; byte[] hashdat = new byte[32]; buffer.position(map.start); buffer.get(hashdat); lock.unlock(); return StoredBlock.deserializeCompact(params, buffer); }

Target:
public StoredBlock get(Sha256Hash hash) throws BlockStoreException { lock.lock(); StoredBlock block; try { final MappedByteBuffer buffer = this.buffer; if (buffer == null) throw new BlockStoreException("Store closed"); ChainMap map = chainMaps.get(hash); if (map == null) return null; byte[] hashdat = new byte[32]; buffer.position(map.start); buffer.get(hashdat); block = StoredBlock.deserializeCompact(params, buffer); } finally { lock.unlock(); } return block; }
Source:
public void highlightElement(Object element, int color) { verifyThreadAccess(); HighlightableDescriptor highlightableDescriptor = getHighlightableDescriptor(element); if (highlightableDescriptor == null) { mHighlighter.clearHighlight(); } else { mHighlightBoundsRect.setEmpty(); highlightableDescriptor.getBoundsForHighlighting(element, mHighlightBoundsRect); mHighlighter.setHighlightedView( highlightableDescriptor.getViewForHighlighting(element), mHighlightBoundsRect, color); } }

Target:
public void highlightElement(Object element, int color) { verifyThreadAccess(); mHighlightingBoundsRect.setEmpty(); final View highlightingView = getHighlightingView(element, mHighlightingBoundsRect); if (highlightingView == null) { mHighlighter.clearHighlight(); } else { mHighlighter.setHighlightedView( highlightingView, mHighlightingBoundsRect, color); } }
Source:
private AuthenticateResponse(String serverResponse) { ObjectServerError error; Token accessToken; Token refreshToken; String message; try { JSONObject obj = new JSONObject(serverResponse); accessToken = obj.has(JSON_FIELD_ACCESS_TOKEN) ? Token.from(obj.getJSONObject(JSON_FIELD_ACCESS_TOKEN)) : null; refreshToken = obj.has(JSON_FIELD_REFRESH_TOKEN) ? Token.from(obj.getJSONObject(JSON_FIELD_REFRESH_TOKEN)) : null; error = null; if (accessToken == null) { message = "accessToken = null"; } else { message = String.format(Locale.ENGLISH, "Identity %s; Path %s", accessToken.identity(), accessToken.path()); } } catch (JSONException ex) { accessToken = null; refreshToken = null; error = new ObjectServerError(ErrorCode.JSON_EXCEPTION, ex); message = String.format(Locale.ENGLISH, "Error %s", error.getErrorMessage()); } RealmLog.debug("AuthenticateResponse. " + message); setError(error); this.accessToken = accessToken; this.refreshToken = refreshToken; }

Target:
private AuthenticateResponse(String serverResponse) { ObjectServerError error; Token accessToken; Token refreshToken; String message; try { JSONObject obj = new JSONObject(serverResponse); accessToken = obj.has(JSON_FIELD_ACCESS_TOKEN) ? Token.from(obj.getJSONObject(JSON_FIELD_ACCESS_TOKEN)) : null; refreshToken = obj.has(JSON_FIELD_REFRESH_TOKEN) ? Token.from(obj.getJSONObject(JSON_FIELD_REFRESH_TOKEN)) : null; error = null; if (accessToken == null) { message = "accessToken = null"; } else { message = String.format(Locale.US, "Identity %s; Path %s", accessToken.identity(), accessToken.path()); } } catch (JSONException ex) { accessToken = null; refreshToken = null; error = new ObjectServerError(ErrorCode.JSON_EXCEPTION, ex); message = String.format(Locale.US, "Error %s", error.getErrorMessage()); } RealmLog.debug("AuthenticateResponse. " + message); setError(error); this.accessToken = accessToken; this.refreshToken = refreshToken; }
Source:
protected TenantStatus getTenantStatus(String tenantDomain) throws LazyLoadingTestException { TenantStatus tenantStatus; String requestUrl = webAppURL + "/" + IS_TENANT_LOADED_METHOD_URL + "/" + tenantDomain; try { HttpResponse response = HttpURLConnectionClient.sendGetRequest(requestUrl, null); JSONObject tenantStatusJSON = new JSONObject(response.getData()); tenantStatus = new TenantStatus(tenantStatusJSON.getJSONObject("TenantStatus"). getBoolean("tenantContextLoaded")); } catch (IOException ioException) { String customErrorMessage = "IOException when sending the Get request to:" + requestUrl + "\n" + ioException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, ioException); } catch (JSONException jsonException) { String customErrorMessage = "JSONException when retrieving the values from json object TenantStatus" + requestUrl + "\n" + jsonException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, jsonException); } return tenantStatus; }

Target:
protected TenantStatusBean getTenantStatus(String tenantDomain) throws LazyLoadingTestException { TenantStatusBean tenantStatus; String requestUrl = supperTenantWebAppURL + "/" + IS_TENANT_LOADED_METHOD_URL + "/" + tenantDomain; try { HttpResponse response = HttpURLConnectionClient.sendGetRequest(requestUrl, null); JSONObject tenantStatusJSON = new JSONObject(response.getData()); tenantStatus = new TenantStatusBean(tenantStatusJSON.getJSONObject("TenantStatus").getBoolean("tenantContextLoaded")); } catch (IOException ioException) { String customErrorMessage = "IOException when sending the Get request to:" + requestUrl; log.error(customErrorMessage, ioException); throw new LazyLoadingTestException(customErrorMessage, ioException); } catch (JSONException jsonException) { String customErrorMessage = "JSONException when retrieving the values from json object TenantStatus" + requestUrl; log.error(customErrorMessage, jsonException); throw new LazyLoadingTestException(customErrorMessage, jsonException); } return tenantStatus; }
Source:
private void testCrudCachePermissions(boolean isClient) throws Exception { String login = isClient ? "client" : "server"; Ignite node = startGrid(login + "_test_node", getSecurityPermissionSet(JOIN_AS_SERVER), isClient); node.createCache(NEW_CACHE); node.createCache(ALL_PERM_TEST_CACHE); node.createCache(CREATE_TEST_CACHE); assertThrowsWithCause(() -> node.createCache(EMPTY_PERM_TEST_CACHE), SecurityException.class); checkOperations(node); assertThrowsWithCause(() -> node.cache(CREATE_TEST_CACHE).destroy(), SecurityException.class); }

Target:
private void testCrudCachePermissions(boolean isClient) throws Exception { Ignite node = startGrid(loginPrefix(isClient) + "_test_node", SecurityPermissionSetBuilder.create() .appendCachePermissions(CACHE_NAME, CACHE_READ, CACHE_PUT, CACHE_REMOVE) .appendCachePermissions(FORBIDDEN_CACHE, EMPTY_PERMS).build(), isClient); for (Consumer<IgniteCache<String, String>> c : operations()) { c.accept(node.cache(CACHE_NAME)); assertThrowsWithCause(() -> c.accept(node.cache(FORBIDDEN_CACHE)), SecurityException.class); } }
Source:
protected void configure() { super.configure(); bind(new TypeLiteral<ComputeServiceAdapter<Droplet, Size, Image, Region>>() { }).to(DigitalOceanComputeServiceAdapter.class); bind(new TypeLiteral<Function<Droplet, NodeMetadata>>() { }).to(DropletToNodeMetadata.class); bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() { }).to(ImageToImage.class); bind(new TypeLiteral<Function<Region, Location>>() { }).to(RegionToLocation.class); bind(new TypeLiteral<Function<Size, Hardware>>() { }).to(SizeToHardware.class); bind(new TypeLiteral<Function<Droplet.Status, Status>>() { }).to(DropletStatusToStatus.class); install(new LocationsFromComputeServiceAdapterModule<Droplet, Size, Image, Region>() { }); bind(TemplateOptions.class).to(DigitalOceanTemplateOptions.class); bind(TemplateOptionsToStatement.class).to(TemplateOptionsToStatementWithoutPublicKey.class); bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(PopulateDefaultCredentialsToImage.class); bind(new TypeLiteral<ImageExtension>() { }).to(DigitalOceanImageExtension.class); }

Target:
protected void configure() { super.configure(); bind(new TypeLiteral<ComputeServiceAdapter<Droplet, Size, Image, Region>>() { }).to(DigitalOceanComputeServiceAdapter.class); bind(new TypeLiteral<Function<Droplet, NodeMetadata>>() { }).to(DropletToNodeMetadata.class); bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() { }).to(ImageToImage.class); bind(new TypeLiteral<Function<Region, Location>>() { }).to(RegionToLocation.class); bind(new TypeLiteral<Function<Size, Hardware>>() { }).to(SizeToHardware.class); bind(new TypeLiteral<Function<Droplet.Status, Status>>() { }).to(DropletStatusToStatus.class); install(new LocationsFromComputeServiceAdapterModule<Droplet, Size, Image, Region>() { }); bind(TemplateOptions.class).to(DigitalOceanTemplateOptions.class); bind(TemplateOptionsToStatement.class).to(TemplateOptionsToStatementWithoutPublicKey.class); bind(new TypeLiteral<ImageExtension>() { }).to(DigitalOceanImageExtension.class); }
Source:
public static PreReceiveHook newChain(List<? extends PreReceiveHook> hooks) { PreReceiveHook[] newHooks = new PreReceiveHook[hooks.size()]; int i = 0; for (PreReceiveHook hook : hooks) { if (hook != PreReceiveHook.NULL) newHooks[i++] = hook; } if (i == 0) return PreReceiveHook.NULL; else if (i == 1) return newHooks[0]; else return new PreReceiveHookChain(newHooks); }

Target:
public static PreReceiveHook newChain(List<? extends PreReceiveHook> hooks) { PreReceiveHook[] newHooks = new PreReceiveHook[hooks.size()]; int i = 0; for (PreReceiveHook hook : hooks) if (hook != PreReceiveHook.NULL) newHooks[i++] = hook; if (i == 0) return PreReceiveHook.NULL; else if (i == 1) return newHooks[0]; else return new PreReceiveHookChain(newHooks, i); }
Source:
public static File makeDimFile(File dir, String dimension) { return new File(dir, StringUtils.safeFormat("dim_%s.drd", dimension)); }

Target:
public static File makeDimFile(File dir, String dimension) { return new File(dir, StringUtils.format("dim_%s.drd", dimension)); }
Source:
public void testPollAndResponseHandling() throws Exception { NonBlockingRouter.currentOperationsCount.incrementAndGet(); GetBlobInfoOperation op = new GetBlobInfoOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobIdStr, options, null, routerCallback, kms, cryptoService, cryptoJobHandler, time); ArrayList<RequestInfo> requestListToFill = new ArrayList<>(); requestRegistrationCallback.requestListToFill = requestListToFill; op.poll(requestRegistrationCallback); Assert.assertEquals("There should only be as many requests at this point as requestParallelism", requestParallelism, correlationIdToGetOperation.size()); CountDownLatch onPollLatch = new CountDownLatch(1); if (testEncryption) { routerCallback.setOnPollLatch(onPollLatch); } List<ResponseInfo> responses = sendAndWaitForResponses(requestListToFill); for (ResponseInfo responseInfo : responses) { GetResponse getResponse = responseInfo.getError() == null ? GetResponse.readFrom( new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse())), mockClusterMap) : null; op.handleResponse(responseInfo, getResponse); if (op.isOperationComplete()) { break; } } if (testEncryption) { Assert.assertTrue("Latch should have been zeroed ", onPollLatch.await(5000, TimeUnit.MILLISECONDS)); op.poll(requestRegistrationCallback); } Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); assertSuccess(op); }

Target:
public void testPollAndResponseHandling() throws Exception { NonBlockingRouter.currentOperationsCount.incrementAndGet(); GetBlobInfoOperation op = new GetBlobInfoOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobId, options, null, routerCallback, kms, cryptoService, cryptoJobHandler, time); ArrayList<RequestInfo> requestListToFill = new ArrayList<>(); requestRegistrationCallback.requestListToFill = requestListToFill; op.poll(requestRegistrationCallback); Assert.assertEquals("There should only be as many requests at this point as requestParallelism", requestParallelism, correlationIdToGetOperation.size()); CountDownLatch onPollLatch = new CountDownLatch(1); if (testEncryption) { routerCallback.setOnPollLatch(onPollLatch); } List<ResponseInfo> responses = sendAndWaitForResponses(requestListToFill); for (ResponseInfo responseInfo : responses) { GetResponse getResponse = responseInfo.getError() == null ? GetResponse.readFrom( new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse())), mockClusterMap) : null; op.handleResponse(responseInfo, getResponse); if (op.isOperationComplete()) { break; } } if (testEncryption) { Assert.assertTrue("Latch should have been zeroed ", onPollLatch.await(500, TimeUnit.MILLISECONDS)); op.poll(requestRegistrationCallback); } Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); assertSuccess(op); }
Source:
protected int resolveParallelBenchmarkCount() { int availableProcessorCount = Runtime.getRuntime().availableProcessors(); int resolvedParallelBenchmarkCount; if (parallelBenchmarkCount == null) { resolvedParallelBenchmarkCount = 1; } else if (parallelBenchmarkCount.equals(PARALLEL_BENCHMARK_COUNT_AUTO)) { resolvedParallelBenchmarkCount = resolveParallelBenchmarkCountAutomatically(availableProcessorCount); } else { resolvedParallelBenchmarkCount = resolveParallelBenchmarkCountFromFormula(availableProcessorCount); } if (resolvedParallelBenchmarkCount < 1) { throw new IllegalArgumentException("The parallelBenchmarkCount (" + parallelBenchmarkCount + ") resulted in a resolvedParallelBenchmarkCount (" + resolvedParallelBenchmarkCount + ") that is lower than 1."); } if (resolvedParallelBenchmarkCount > availableProcessorCount) { logger.warn("Because the resolvedParallelBenchmarkCount (" + resolvedParallelBenchmarkCount + ") is higher than the availableProcessorCount (" + availableProcessorCount + "), it is reduced to availableProcessorCount."); resolvedParallelBenchmarkCount = availableProcessorCount; } return resolvedParallelBenchmarkCount; }

Target:
protected int resolveParallelBenchmarkCount() { int availableProcessorCount = Runtime.getRuntime().availableProcessors(); int resolvedParallelBenchmarkCount; if (parallelBenchmarkCount == null) { resolvedParallelBenchmarkCount = 1; } else if (parallelBenchmarkCount.equals(PARALLEL_BENCHMARK_COUNT_AUTO)) { resolvedParallelBenchmarkCount = resolveParallelBenchmarkCountAutomatically(availableProcessorCount); } else { resolvedParallelBenchmarkCount = ConfigUtils.resolveThreadPoolSizeScript( "parallelBenchmarkCount", parallelBenchmarkCount, PARALLEL_BENCHMARK_COUNT_AUTO); } if (resolvedParallelBenchmarkCount < 1) { throw new IllegalArgumentException("The parallelBenchmarkCount (" + parallelBenchmarkCount + ") resulted in a resolvedParallelBenchmarkCount (" + resolvedParallelBenchmarkCount + ") that is lower than 1."); } if (resolvedParallelBenchmarkCount > availableProcessorCount) { logger.warn("Because the resolvedParallelBenchmarkCount (" + resolvedParallelBenchmarkCount + ") is higher than the availableProcessorCount (" + availableProcessorCount + "), it is reduced to availableProcessorCount."); resolvedParallelBenchmarkCount = availableProcessorCount; } return resolvedParallelBenchmarkCount; }
Source:
public void addWhiteListPatterns(String... patterns) { this.whiteListPatterns.addAll(Arrays.asList(patterns)); }

Target:
public void addWhiteListPatterns(String... patterns) { Collections.addAll(this.whiteListPatterns, patterns); }
Source:
public boolean isFailed(SdxClusterStatusResponse datalakeStatus) { Collection<SdxClusterStatusResponse> failedStatuses = List.of(PROVISIONING_FAILED, REPAIR_FAILED, UPGRADE_FAILED, DATALAKE_UPGRADE_FAILED, DELETE_FAILED, START_FAILED, STOP_FAILED, SYNC_FAILED); return failedStatuses.contains(datalakeStatus); }

Target:
public boolean isFailed(SdxClusterStatusResponse datalakeStatus) { Set<SdxClusterStatusResponse> failedStatuses = Set.of(PROVISIONING_FAILED, REPAIR_FAILED, UPGRADE_FAILED, DATALAKE_UPGRADE_FAILED, DELETE_FAILED, START_FAILED, STOP_FAILED, SYNC_FAILED); return failedStatuses.contains(datalakeStatus); }
Source:
public static FunctionInfo getFunctionByName(String functionName) { return FUNCTION_INFO_MAP.get(functionName.toLowerCase()); }

Target:
public static FunctionInfo getFunctionByName(String functionName) { return FUNCTION_INFO_MAP.get(canonicalize(functionName)); }
Source:
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras(); if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { if (extras != null) { dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE, false)); } } else if (CONNECTIVITY_ACTION.equals(action)) { dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo()); } }

Target:
@Override public void onReceive(Context context, Intent intent) { if (null == intent) { return; } String action = intent.getAction(); Bundle extras = intent.getExtras(); if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE, false)); } else if (CONNECTIVITY_ACTION.equals(action)) { dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo()); } }
Source:
private void updateLabelList() { AsyncDataProvider.getInstance().getLabelList(new AsyncQuery<>(allLabels -> { if (getIsNew()) { labelList.setItems(allLabels); labelList.setSelectedItems(new ArrayList<>()); } else { AsyncDataProvider.getInstance().getLabelListByEntityId(new AsyncQuery<>(hostLabelsList -> { labelList.setItems(allLabels); labelList.setSelectedItems(hostLabelsList); }), getHostId()); } labelList.setIsChangeable(true); })); }

Target:
private void updateLabelList() { AsyncDataProvider.getInstance().getLabelList(new AsyncQuery<>(allLabels -> { if (getIsNew()) { labelList.setItems(allLabels); labelList.setSelectedItems(new ArrayList<>()); } else { AsyncDataProvider.getInstance().getLabelListByEntityId(new AsyncQuery<>(hostLabelsList -> { labelList.setItems(allLabels); labelList.setSelectedItems(hostLabelsList); }), getHostId()); } })); }
Source:
public Plan optimize(final Map<String, List<EvaluatorParameters>> evalParamsMap, final int availableEvaluators) { if (callsSkipped < callsToSkip) { callsSkipped++; return PlanImpl.newBuilder().build(); } if (callsMade == maxCallsToMake || evalParamsMap.isEmpty()) { return PlanImpl.newBuilder().build(); } final String evaluatorToAdd = "new-" + callsMade; callsMade++; final PlanImpl.Builder planBuilder = PlanImpl.newBuilder(); for (final String namespace : evalParamsMap.keySet()) { EvaluatorParameters srcEvaluator = null; for (final EvaluatorParameters evaluator : evalParamsMap.get(namespace)) { if (!evaluator.getDataInfos().isEmpty()) { srcEvaluator = evaluator; break; } } if (srcEvaluator == null) { LOG.log(Level.WARNING, "Cannot choose source evaluator to move its data to new evaluator in {0}", namespace); planBuilder.addEvaluatorToAdd(namespace, evaluatorToAdd); continue; } final DataInfo srcDataInfo = srcEvaluator.getDataInfos().iterator().next(); final int numUnitsToMove = srcDataInfo.getNumUnits() / 2; final TransferStep transferStep = new TransferStepImpl( srcEvaluator.getId(), evaluatorToAdd, new DataInfoImpl(srcDataInfo.getDataType(), numUnitsToMove)); planBuilder.addEvaluatorToAdd(namespace, evaluatorToAdd); planBuilder.addTransferStep(namespace, transferStep); } return planBuilder.build(); }

Target:
public Plan optimize(final Map<String, List<EvaluatorParameters>> evalParamsMap, final int availableEvaluators) { if (callsSkipped < callsToSkip) { callsSkipped++; return PlanImpl.newBuilder().build(); } if (callsMade == maxCallsToMake || evalParamsMap.isEmpty()) { return PlanImpl.newBuilder().build(); } final String evaluatorToAdd = "new-" + callsMade; callsMade++; final PlanImpl.Builder planBuilder = PlanImpl.newBuilder(); for (final String namespace : evalParamsMap.keySet()) { planBuilder.addEvaluatorToAdd(namespace, evaluatorToAdd); EvaluatorParameters srcEvaluator = null; for (final EvaluatorParameters evaluator : evalParamsMap.get(namespace)) { if (!evaluator.getDataInfos().isEmpty()) { srcEvaluator = evaluator; break; } } if (srcEvaluator == null) { LOG.log(Level.WARNING, "Cannot choose source evaluator to move its data to new evaluator in {0}", namespace); continue; } final DataInfo srcDataInfo = srcEvaluator.getDataInfos().iterator().next(); final int numUnitsToMove = srcDataInfo.getNumUnits() / 2; final TransferStep transferStep = new TransferStepImpl( srcEvaluator.getId(), evaluatorToAdd, new DataInfoImpl(srcDataInfo.getDataType(), numUnitsToMove)); planBuilder.addTransferStep(namespace, transferStep); } return planBuilder.build(); }
Source:
protected void serviceStart() throws UnknownHostException { String localHostName = InetAddress.getLocalHost().getHostName(); LOG.debug("Local hostname is: {}", localHostName); for (String hostName : hostNames) { if (hostName.equalsIgnoreCase(localHostName)) { LOG.debug("Starting load generator process on: {}", localHostName); processors = Runtime.getRuntime().availableProcessors(); threads = new Thread[processors]; Random random = new Random(); for (int i = 0; i < processors; i++) { threads[i] = new Thread(new Runnable() { @Override public void run() { while (!Thread.interrupted()) { if (random.nextFloat() <= threshold) { long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < INTERVAL) { } } else { try { Thread.sleep(INTERVAL); } catch (InterruptedException e) { } } } } }); threads[i].start(); } } } }

Target:
protected void serviceStart() throws UnknownHostException { String localHostName = InetAddress.getLocalHost().getHostName(); LOG.debug("Local hostname is: {}", localHostName); for (String hostName : victimsHostName) { if (hostName.equalsIgnoreCase(localHostName)) { LOG.debug("Starting load generator process on: {}", localHostName); threads = new Thread[Runtime.getRuntime().availableProcessors()]; Random random = new Random(); for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { @Override public void run() { while (!Thread.interrupted()) { if (random.nextFloat() <= threshold) { long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < interval) { if (Thread.currentThread().isInterrupted()) { break; } } } else { try { Thread.sleep(interval); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } } }); threads[i].start(); } } } }
Source:
private void build() { initRootPage(); initMessagesPart(); initButtonsPart(); this.window = new Window(); this.window.setTitle("Plan a job"); this.window.setShowMinimizeButton(false); this.window.setIsModal(true); this.window.setShowModalMask(true); this.window.addItem(rootPage); this.window.setWidth(this.width); this.window.setHeight(this.height); this.window.centerInPage(); this.window.setCanDragResize(true); }

Target:
private void build() { initRootPage(); initMessagesPart(); initButtonsPart(); this.window = new Window(); this.window.setTitle("Plan a job"); this.window.setShowMinimizeButton(false); this.window.setIsModal(true); this.window.setShowModalMask(true); this.window.addItem(rootPage); this.window.setWidth(WIDTH); this.window.setHeight(HEIGHT); this.window.centerInPage(); this.window.setCanDragResize(true); }
Source:
public static void start(String... args) { JCommanderCommandProvider commandProvider = JCommanderCommandProvider.get(); final RemoteMainJCommanderCommand mainCommand = new RemoteMainJCommanderCommand(); LOGGER.debug("Registering commands with JCommanderCommandRepository"); JCommanderCommandRepository commandRepository = new JCommanderCommandRepository(); Set<JCommanderCommand> commands = commandProvider.getCommands(); commands.add(mainCommand); commandRepository.addAll(commands); LOGGER.debug("Parsing command-line arguments"); CustomJCommander jCommander = parseArguments(commandRepository, mainCommand, args); mainCommand.validate(); mainCommand.run(); Collection<Object> services = ServiceProvider.get().createServices((RemoteMainCommand)mainCommand.getCommand()); jCommander.getAskedCommand().map(command -> { if (command.isHelp()) { jCommander.printUsage(); return true; } else { LOGGER.debug("Injecting services in specified command"); Injector.inject(command.getCommand(), services); command.validate(); command.run(); return true; } }).orElseGet(() -> { jCommander.usage(); return false; }); }

Target:
public static void start(String... args) { JCommanderCommandProvider commandProvider = JCommanderCommandProvider.get(); final RemoteMainJCommanderCommand mainCommand = new RemoteMainJCommanderCommand(); LOGGER.debug("Registering commands with JCommanderCommandRepository"); JCommanderCommandRepository commandRepository = new JCommanderCommandRepository(); Set<JCommanderCommand> commands = commandProvider.getCommands(); commands.add(mainCommand); commandRepository.addAll(commands); LOGGER.debug("Parsing command-line arguments"); CustomJCommander jCommander = parseArguments(commandRepository, mainCommand, args); mainCommand.validate(); mainCommand.run(); Collection<Object> services = ServiceProvider.get().createServices(mainCommand.getCommand()); jCommander.getAskedCommand().map(command -> { if (command.isHelp()) { jCommander.printUsage(); return true; } else { LOGGER.debug("Injecting services in specified command"); Injector.inject(command.getCommand(), services); command.validate(); command.run(); return true; } }).orElseGet(() -> { jCommander.usage(); return false; }); }
Source:
private void setupTestService(String requestId, String serviceId, String basePath, Optional<String> replaceServiceId, Optional<Map<String, Object>> options, Optional<String> template) { System.out.println("Requesting " + requestId + "..."); UpstreamInfo upstream = new UpstreamInfo(UPSTREAM, Optional.<String>absent(), Optional.<String>absent()); BaragonService lbService = new BaragonService(serviceId, new ArrayList<String>(), basePath, new HashSet<String>(Arrays.asList(LOAD_BALANCER_GROUP)), options.isPresent() ? options.get() : new HashMap<String, Object>(), template); BaragonRequest request = new BaragonRequest(requestId, lbService, Arrays.asList(upstream), new ArrayList<UpstreamInfo>(), replaceServiceId); baragonServiceClient.enqueueRequest(request); }

Target:
private void setupTestService(String requestId, String serviceId, String basePath, Optional<String> replaceServiceId, Optional<Map<String, Object>> options, Optional<String> template) { UpstreamInfo upstream = new UpstreamInfo(UPSTREAM, Optional.<String>absent(), Optional.<String>absent()); BaragonService lbService = new BaragonService(serviceId, new ArrayList<String>(), basePath, new HashSet<String>(Arrays.asList(LOAD_BALANCER_GROUP)), options.isPresent() ? options.get() : new HashMap<String, Object>(), template); BaragonRequest request = new BaragonRequest(requestId, lbService, Arrays.asList(upstream), new ArrayList<UpstreamInfo>(), replaceServiceId); baragonServiceClient.enqueueRequest(request); }
Source:
public void run() { MessageContext context = null; ObjectMapper mapper = new ObjectMapper(); while (true) { try { context = this.queue.take(); if (context.getClient() == null) { break; } if (log.isDebugEnabled()) { log.debug("Message received: " + new String(context.getMessage(), UTF8)); } JsonNode rootNode = mapper.readTree(context.getMessage()); if (!rootNode.isArray()) { processIncomingObject(context.getClient(), rootNode); } else { final Iterator<JsonNode> iter = rootNode.getElements(); while (iter.hasNext()) { final JsonNode node = iter.next(); processIncomingObject(context.getClient(), node); } } } catch (Exception e) { log.warn("Exception thrown during message processing"); continue; } } }

Target:
public void run() { MessageContext context = null; ObjectMapper mapper = new ObjectMapper(); while (true) { try { context = this.queue.take(); if (context.getClient() == null) { break; } if (log.isDebugEnabled()) { log.debug("Message received: " + new String(context.getMessage(), UTF8)); } JsonNode rootNode = mapper.readTree(context.getMessage()); if (!rootNode.isArray()) { processIncomingObject(context.getClient(), rootNode); } else { final Iterator<JsonNode> iter = rootNode.getElements(); while (iter.hasNext()) { final JsonNode node = iter.next(); processIncomingObject(context.getClient(), node); } } } catch (Exception e) { log.warn("Exception thrown during message processing"); if (log.isDebugEnabled()) { log.debug(e.getMessage(), e); } continue; } } }
Source:
public Map<Measure, Result<?>> calculate( T target, Set<Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData) { boolean measureRequested = measures.contains(calculationFunction.measure()); Set<Measure> requiredMeasures = requiredMeasuresSupported && measureRequested ? Sets.union(measures, calculationFunction.requiredMeasures()) : measures; Map<Measure, Result<?>> delegateResults = delegate.calculate(target, requiredMeasures, parameters, marketData, refData); if (!measureRequested) { return delegateResults; } Result<?> result = calculateMeasure(target, delegateResults, parameters, marketData, refData); Map<Measure, Result<?>> requestedResults = MapStream.of(delegateResults) .filterKeys(measures::contains) .filterKeys(measure -> !measure.equals(calculationFunction.measure())) .toMap(); return ImmutableMap.<Measure, Result<?>>builder() .put(calculationFunction.measure(), result) .putAll(requestedResults) .build(); }

Target:
public Map<Measure, Result<?>> calculate( T target, Set<Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData) { if (!measures.contains(derivedFunction.measure())) { return delegate.calculate(target, measures, parameters, marketData, refData); } Set<Measure> requiredMeasures = Sets.union(measures, derivedFunction.requiredMeasures()); Map<Measure, Result<?>> delegateResults = delegate.calculate(target, requiredMeasures, parameters, marketData, refData); Result<?> result = calculateMeasure(target, delegateResults, parameters, marketData, refData); Map<Measure, Result<?>> requestedResults = MapStream.of(delegateResults) .filterKeys(measures::contains) .filterKeys(measure -> !measure.equals(derivedFunction.measure())) .toMap(); return ImmutableMap.<Measure, Result<?>>builder() .put(derivedFunction.measure(), result) .putAll(requestedResults) .build(); }
Source:
private static String stripLeadingZeros(String input) { for (int i = 0; i < input.length(); i++) { if (input.charAt(i) != '0') { return input.substring(i); } } return ""; }

Target:
private static String stripLeadingZeros(String input) { for (int i = 0; i < input.length(); i++) if (input.charAt(i) != '0') return input.substring(i); return ""; }
Source:
public IContainerDMContext[] getTargetFilters() throws CoreException { synchronized (fFilteredThreadsByTarget) { Set<IContainerDMContext> set = fFilteredThreadsByTarget.keySet(); return set.toArray(new IContainerDMContext[set.size()]); } }

Target:
public IContainerDMContext[] getTargetFilters() throws CoreException { Set<IContainerDMContext> set = fFilteredThreadsByTarget.keySet(); synchronized (fFilteredThreadsByTarget) { return set.toArray(new IContainerDMContext[set.size()]); } }
Source:
static void loadGame(final String path) { try { final URL pathURL = new File(path).toURI().toURL(); final InputStream stream = pathURL.openStream(); final Base64Reader reader = new Base64Reader(new BufferedReader( new InputStreamReader(stream, "UTF-8"))); final String mainString = reader.readString(); final JSONParser parser = new JSONParser(); final JSONObject mainObject = (JSONObject) parser.parse(mainString); parseJSON(mainObject); writeToState(); writeToSkins(); reader.close(); } catch (IOException e) { OBSERVABLE.notify(Category.ERROR, Error.IOEXCEPTION, "Parser.loadGame(String)", e.getMessage()); } catch (ParseException e) { OBSERVABLE.notify(Category.ERROR, Error.PARSEEXCEPTION, "Parser.loadGame(String)", e.getMessage()); } }

Target:
static void loadGame(final String path) { try { final URL pathURL = new File(path).toURI().toURL(); final InputStream stream = pathURL.openStream(); final Base64Reader reader = new Base64Reader(new BufferedReader( new InputStreamReader(stream, "UTF-8"))); final String mainString = reader.readString(); final JSONParser parser = new JSONParser(); final JSONObject mainObject = (JSONObject) parser.parse(mainString); parseJSON(mainObject); writeToState(); writeToSkins(); writeToSoundtracks(); reader.close(); } catch (IOException e) { OBSERVABLE.notify(Category.ERROR, Error.IOEXCEPTION, "Parser.loadGame(String)", e.getMessage()); } catch (ParseException e) { OBSERVABLE.notify(Category.ERROR, Error.PARSEEXCEPTION, "Parser.loadGame(String)", e.getMessage()); } }
Source:
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator, Session session) { ProjectNode parent = (ProjectNode) node; PlanNode child = lookup.resolve(parent.getSource()); if (!(child instanceof JoinNode)) { return Optional.empty(); } JoinNode joinNode = (JoinNode) child; if (!joinNode.isCrossJoin()) { return Optional.empty(); } return pruneInputs(child.getOutputSymbols(), parent.getAssignments().getExpressions()) .map(ImmutableSet::copyOf) .map(dependencies -> parent.replaceChildren(ImmutableList.of( joinNode.replaceChildren(ImmutableList.of( restrictOutputs(idAllocator, joinNode.getLeft(), dependencies).orElse(joinNode.getLeft()), restrictOutputs(idAllocator, joinNode.getRight(), dependencies).orElse(joinNode.getRight())))))); }

Target:
public Optional<PlanNode> apply(PlanNode node, Lookup lookup, PlanNodeIdAllocator idAllocator, SymbolAllocator symbolAllocator, Session session) { ProjectNode parent = (ProjectNode) node; PlanNode child = lookup.resolve(parent.getSource()); if (!(child instanceof JoinNode)) { return Optional.empty(); } JoinNode joinNode = (JoinNode) child; if (!joinNode.isCrossJoin()) { return Optional.empty(); } return pruneInputs(child.getOutputSymbols(), parent.getAssignments().getExpressions()) .map(ImmutableSet::copyOf) .map(dependencies -> parent.replaceChildren(ImmutableList.of( restrictChildOutputs(idAllocator, joinNode, dependencies, dependencies).get()))); }
Source:
GssapiServer(final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler callbackHandler) throws SaslException { super(GSSAPI, protocol, serverName, props, callbackHandler, log); GSSManager manager = GSSManager.getInstance(); GSSContext gssContext = null; GSSCredential ourCredential = null; ServerCredentialCallback gssCredentialCallback = new ServerCredentialCallback(GSSKerberosCredential.class); try { log.trace("Obtaining GSSCredential for the service from callback handler..."); callbackHandler.handle(new Callback[] { gssCredentialCallback }); ourCredential = gssCredentialCallback.applyToCredential(GSSKerberosCredential.class, GSSKerberosCredential::getGssCredential); } catch (IOException | UnsupportedCallbackException e) { log.trace("Unable to obtain GSSCredential from CallbackHandler", e); } try { if (ourCredential == null) { String localName = protocol + "@" + serverName; log.tracef("Our name '%s'", localName); GSSName ourName = manager.createName(localName, GSSName.NT_HOSTBASED_SERVICE, KERBEROS_V5); ourCredential = manager.createCredential(ourName, GSSContext.INDEFINITE_LIFETIME, KERBEROS_V5, GSSCredential.ACCEPT_ONLY); } gssContext = manager.createContext(ourCredential); } catch (GSSException e) { throw log.mechUnableToCreateGssContext(getMechanismName(), e).toSaslException(); } this.gssContext = gssContext; }

Target:
GssapiServer(final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler callbackHandler) throws SaslException { super(GSSAPI, protocol, serverName, props, callbackHandler, log); GSSManager manager = GSSManager.getInstance(); GSSContext gssContext = null; GSSCredential ourCredential = null; ServerCredentialCallback gssCredentialCallback = new ServerCredentialCallback(GSSKerberosCredential.class); try { log.trace("Obtaining GSSCredential for the service from callback handler..."); callbackHandler.handle(new Callback[] { gssCredentialCallback }); ourCredential = gssCredentialCallback.applyToCredential(GSSKerberosCredential.class, GSSKerberosCredential::getGssCredential); } catch (IOException e) { throw log.mechCallbackHandlerFailedForUnknownReason(GSSAPI, e).toSaslException(); } catch (UnsupportedCallbackException e) { log.trace("Unable to obtain GSSCredential from CallbackHandler", e); } try { if (ourCredential == null) { String localName = protocol + "@" + serverName; log.tracef("Our name '%s'", localName); GSSName ourName = manager.createName(localName, GSSName.NT_HOSTBASED_SERVICE, KERBEROS_V5); ourCredential = manager.createCredential(ourName, GSSContext.INDEFINITE_LIFETIME, KERBEROS_V5, GSSCredential.ACCEPT_ONLY); } gssContext = manager.createContext(ourCredential); } catch (GSSException e) { throw log.mechUnableToCreateGssContext(getMechanismName(), e).toSaslException(); } this.gssContext = gssContext; }
Source:
public Collection<Replay> getLocalReplays() { Collection<Replay> replayInfos = new ArrayList<>(); String replayFileGlob = clientProperties.getReplay().getReplayFileGlob(); Path replaysDirectory = preferencesService.getReplaysDirectory(); if (Files.notExists(replaysDirectory)) { noCatch(() -> createDirectories(replaysDirectory)); } try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob)) { for (Path replayFile : directoryStream) { try { LocalReplayInfo replayInfo = replayFileReader.parseMetaData(replayFile); FeaturedMod featuredMod = modService.getFeaturedMod(replayInfo.getFeaturedMod()).get(); mapService.findByMapFolderName(replayInfo.getMapname()) .thenAccept(mapBean -> { if (!mapBean.isPresent()) { notificationService.addNotification(new ImmediateNotification( i18n.get("errorTitle"), i18n.get("mapNotFound", replayInfo.getMapname()), WARN )); return; } replayInfos.add(new Replay(replayInfo, replayFile, featuredMod, mapBean.get())); }); } catch (Exception e) { logger.warn("Could not read replay file ({})", replayFile, e.getMessage()); moveCorruptedReplayFile(replayFile); } } } return replayInfos; }

Target:
public CompletableFuture<Collection<Replay>> getLocalReplays() { Collection<Replay> replayInfos = new ArrayList<>(); ArrayList<CompletableFuture<LocalReplayInfo>> localReplayInfoFutures = new ArrayList<>(); String replayFileGlob = clientProperties.getReplay().getReplayFileGlob(); Path replaysDirectory = preferencesService.getReplaysDirectory(); if (Files.notExists(replaysDirectory)) { noCatch(() -> createDirectories(replaysDirectory)); } try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob)) { for (Path replayFile : directoryStream) { try { LocalReplayInfo replayInfo = replayFileReader.parseMetaData(replayFile); CompletableFuture<LocalReplayInfo> localReplayInfoCompletableFuture = modService.getFeaturedMod(replayInfo.getFeaturedMod()). thenCombine(mapService.findByMapFolderName(replayInfo.getMapname()), (featuredMod, mapBean) -> { if (!mapBean.isPresent()) { notificationService.addNotification(new ImmediateNotification( i18n.get("errorTitle"), i18n.get("mapNotFound", replayInfo.getMapname()), WARN )); throw new IllegalStateException(MessageFormat.format("Map not available for replay with map name: '{}'", replayInfo.getMapname())); } replayInfos.add(new Replay(replayInfo, replayFile, featuredMod, mapBean.get())); return replayInfo; }).exceptionally(throwable -> { onUnableToParseReplay(replayFile, throwable); return null; }); localReplayInfoFutures.add(localReplayInfoCompletableFuture); } catch (Exception e) { onUnableToParseReplay(replayFile, e); } } } CompletableFuture[] arrayOfFutures = new CompletableFuture[localReplayInfoFutures.size()]; localReplayInfoFutures.toArray(arrayOfFutures); return CompletableFuture.allOf(arrayOfFutures).thenApply(aVoid -> replayInfos); }
Source:
@Override public void onContinueClick() { viewPager.setCurrentItem(DescriptionEditTutorialPage.PAGE_TWO.code(), true); }

Target:
@Override public void onContinueClick() { int nextPageIndex = viewPager.getCurrentItem() + 1; int lastPageIndex = viewPager.getAdapter().getCount() - 1; viewPager.setCurrentItem(Math.min(nextPageIndex, lastPageIndex), true); }
Source:
public Optional<DefaultValueBridgeExpectations<BigDecimal, ?>> getDefaultValueBridgeExpectations() { return Optional.of( new DefaultValueBridgeExpectations<BigDecimal, BigDecimal>() { @Override public Class<BigDecimal> getProjectionType() { return BigDecimal.class; } @Override public Class<BigDecimal> getIndexFieldJavaType() { return BigDecimal.class; } @Override public List<BigDecimal> getEntityPropertyValues() { return Arrays.asList( BigDecimal.valueOf( -100000.0 ), BigDecimal.valueOf( -1.0 ), BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, BigDecimal.valueOf( 100000.0 ) ); } @Override public List<BigDecimal> getDocumentFieldValues() { return getEntityPropertyValues(); } @Override public Class<?> getTypeWithValueBridge1() { return TypeWithValueBridge1.class; } @Override public Object instantiateTypeWithValueBridge1(int identifier, BigDecimal propertyValue) { TypeWithValueBridge1 instance = new TypeWithValueBridge1(); instance.id = identifier; instance.myProperty = propertyValue; return instance; } @Override public Class<?> getTypeWithValueBridge2() { return TypeWithValueBridge2.class; } } ); }

Target:
public Optional<DefaultValueBridgeExpectations<BigDecimal, ?>> getDefaultValueBridgeExpectations() { return Optional.of( new DefaultValueBridgeExpectations<BigDecimal, BigDecimal>() { @Override public Class<BigDecimal> getProjectionType() { return BigDecimal.class; } @Override public Class<BigDecimal> getIndexFieldJavaType() { return BigDecimal.class; } @Override public List<BigDecimal> getEntityPropertyValues() { return Arrays.asList( BigDecimal.valueOf( -100000.0 ), BigDecimal.valueOf( -1.0 ), BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, BigDecimal.valueOf( 100000.0 ), BigDecimal.valueOf( 42571524, 231254 ) ); } @Override public List<BigDecimal> getDocumentFieldValues() { return getEntityPropertyValues(); } @Override public Class<?> getTypeWithValueBridge1() { return TypeWithValueBridge1.class; } @Override public Object instantiateTypeWithValueBridge1(int identifier, BigDecimal propertyValue) { TypeWithValueBridge1 instance = new TypeWithValueBridge1(); instance.id = identifier; instance.myProperty = propertyValue; return instance; } @Override public Class<?> getTypeWithValueBridge2() { return TypeWithValueBridge2.class; } } ); }