auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public PaxosLeadershipCreator( TimeLockInstallConfiguration install, Observable<TimeLockRuntimeConfiguration> runtime, Consumer<Object> registrar) { this.install = install; Preconditions.checkState(install.algorithm() instanceof PaxosInstallConfiguration, "Cannot create a Paxos leadership agent with a non-Paxos install configuration"); this.paxosInstall = (PaxosInstallConfiguration) install.algorithm(); this.runtime = runtime.map(config -> config.algorithm().map(algo -> (PaxosRuntimeConfiguration) algo)); this.registrar = registrar; }

Target:
public PaxosLeadershipCreator( TimeLockInstallConfiguration install, Observable<TimeLockRuntimeConfiguration> runtime, Consumer<Object> registrar) { this.install = install; this.runtime = runtime.map(TimeLockRuntimeConfiguration::algorithm); this.registrar = registrar; }
Source:
private String getAuthorizationCommonEndpoint(final URL authorizationEndpointUrl) { return String.format("https://%s%s", authorizationEndpointUrl.getHost(), AUTHORIZATION_COMMON_ENDPOINT); }

Target:
private String getAuthorizationCommonEndpoint(final URL authorizationEndpointUrl) { return new Uri.Builder().scheme("https") .authority(authorizationEndpointUrl.getHost()) .appendPath(AUTHORIZATION_COMMON_ENDPOINT).build().toString(); }
Source:
private Object getSingletonInstance(RenderingContext ctx) { if (!servicesInjected) { synchronized (this) { if (!servicesInjected) { injectServices(singleton); servicesInjected = true; } } } for (Field contextField : contextFields) { ThreadSafeRenderingContext value; try { value = (ThreadSafeRenderingContext) contextField.get(singleton); } catch (IllegalArgumentException | IllegalAccessException e) { log.error("unable to create a marshaller instance for clazz " + clazz.getName(), e); return null; } value.configureThread(ctx); } return singleton; }

Target:
private Object getSingletonInstance(RenderingContext ctx) { if (!servicesInjected) { synchronized (this) { if (!servicesInjected) { injectServices(singleton); servicesInjected = true; } } } for (Field contextField : contextFields) { ThreadSafeRenderingContext value; try { value = (ThreadSafeRenderingContext) contextField.get(singleton); } catch (IllegalArgumentException | IllegalAccessException e) { throw new NuxeoException("unable to create a marshaller instance for clazz " + clazz.getName(), e); } value.configureThread(ctx); } return singleton; }
Source:
protected <I, T extends I> @Nullable I getService(Class<T> clazz, Class<I> implementationClass) { final List<I> services = getServices(clazz, implementationClass); return getSingleServiceInstance(clazz, services); }

Target:
protected <T, I extends T> @Nullable I getService(Class<T> clazz, Class<I> implementationClass) { final List<I> services = getServices(clazz, implementationClass); return getSingleServiceInstance(clazz, services); }
Source:
public Object[] getChildren(final Object parentElement) { if (parentElement instanceof IRepositoryStore) { if (!cache.containsKey(parentElement)) { final List<IRepositoryFileStore> result = new ArrayList<IRepositoryFileStore>(); for (final IRepositoryFileStore child : ((IRepositoryStore<IRepositoryFileStore>) parentElement).getChildren()) { if (child != null && child.canBeExported()) { result.add(child); } } cache.put((IRepositoryStore<?>) parentElement, result.toArray()); } return cache.get(parentElement); } return null; }

Target:
public Object[] getChildren(final Object parentElement) { if (parentElement instanceof IRepositoryStore) { if (!cache.containsKey(parentElement)) { final List<IRepositoryFileStore> result = new ArrayList<IRepositoryFileStore>(); for (final IRepositoryFileStore child : ((IRepositoryStore<IRepositoryFileStore>) parentElement).getChildren()) { if (child != null && child.canBeExported()) { result.add(child); } } cache.put((IRepositoryStore<?>) parentElement, result.toArray()); } return cache.get(parentElement); } return new Object[0]; }
Source:
public void addFeature(PhoneNumberFeature... features) { for (PhoneNumberFeature feature: features) { this.features.add(feature); } }

Target:
public void addFeature(PhoneNumberFeature... features) { Collections.addAll(this.features, features); }
Source:
public void onPartitionBecomeStandbyFromLeader(String partitionName) { try { PartitionStateChangeListener cloudToStoreReplicationListener = partitionStateChangeListeners.get(StateModelListenerType.CloudToStoreReplicationManagerListener); if (cloudToStoreReplicationListener != null) { cloudToStoreReplicationListener.onPartitionBecomeStandbyFromLeader(partitionName); } } catch (Exception e) { participantMetrics.leaderCount.addAndGet(-1); participantMetrics.errorStateCount.addAndGet(1); throw e; } participantMetrics.leaderCount.addAndGet(-1); participantMetrics.standbyCount.addAndGet(1); }

Target:
public void onPartitionBecomeStandbyFromLeader(String partitionName) { try { PartitionStateChangeListener cloudToStoreReplicationListener = partitionStateChangeListeners.get(StateModelListenerType.CloudToStoreReplicationManagerListener); if (cloudToStoreReplicationListener != null) { cloudToStoreReplicationListener.onPartitionBecomeStandbyFromLeader(partitionName); } } catch (Exception e) { participantMetrics.errorStateCount.addAndGet(1); throw e; } finally { participantMetrics.leaderCount.addAndGet(-1); } participantMetrics.standbyCount.addAndGet(1); }
Source:
public static VerificationClientService verificationClientServiceDialogue( VerificationClientRule verificationClientRule) { Channel channel = ApacheHttpClientChannels.create(ClientConfiguration.builder() .from(verificationClientRule.getClientConfiguration()) .userAgent(getUserAgent()) .build()); return JaxRsClient.create( VerificationClientService.class, DefaultConjureRuntime.builder().build(), channel); }

Target:
public static VerificationClientService verificationClientServiceDialogue( VerificationClientRule verificationClientRule) { Channel channel = ApacheHttpClientChannels.create(verificationClientRule.getClientConfiguration()); return JaxRsClient.create( VerificationClientService.class, channel, DefaultConjureRuntime.builder().build()); }
Source:
void setOperationException(Exception exception) { if (exception instanceof RouterException) { RouterErrorCode routerErrorCode = ((RouterException) exception).getErrorCode(); if (operationException.get() == null) { operationException.set(exception); } else { if (getPrecedenceLevel(routerErrorCode) < getPrecedenceLevel( ((RouterException) operationException.get()).getErrorCode())) { operationException.set(exception); } } } else { if (operationException.get() == null) { operationException.set(exception); } } }

Target:
void setOperationException(Exception exception) { if (exception instanceof RouterException) { RouterErrorCode routerErrorCode = ((RouterException) exception).getErrorCode(); if (operationException.get() == null) { operationException.set(exception); } else { Integer currentOperationExceptionLevel = null; if (operationException.get() instanceof RouterException) { currentOperationExceptionLevel = getPrecedenceLevel(((RouterException) operationException.get()).getErrorCode()); } else { currentOperationExceptionLevel = getPrecedenceLevel(RouterErrorCode.UnexpectedInternalError); } if (getPrecedenceLevel(routerErrorCode) < currentOperationExceptionLevel) { operationException.set(exception); } } } else { if (operationException.get() == null) { operationException.set(exception); } } }
Source:
public void setSplitRules(final Collection<SplitRule> splitRules) { this.splitRules = splitRules; if (this.splitRules.size() != 0) { addUnsavedProperty("splitRules"); } }

Target:
public void setSplitRules(final Collection<SplitRule> splitRules) { this.splitRules = splitRules; }
Source:
public String printTopologyFromLevel(Set<Integer> bridgeIds, int level) { Set<Integer> bridgesDownLevel = new HashSet<Integer>(); StringBuffer strbfr = new StringBuffer(); strbfr.append("------level "); strbfr.append(level); strbfr.append(" -----\n"); strbfr.append("bridges on level:"); strbfr.append(bridgeIds); strbfr.append("\n"); for (Integer bridgeid : bridgeIds) { final Bridge bridge = getBridge(bridgeid); if (bridge == null) { continue; } strbfr.append(bridge.printTopology()); for (SharedSegment segment: getSharedSegmentOnTopologyForBridge(bridgeid)) { if (segment.getDesignatedBridge().intValue() == bridgeid.intValue()) { strbfr.append(segment.printTopology()); bridgesDownLevel.addAll(segment.getBridgeIdsOnSegment()); } } } strbfr.append("------level "); strbfr.append(level); strbfr.append(" -----\n"); bridgesDownLevel.removeAll(bridgeIds); if (!bridgesDownLevel.isEmpty()) strbfr.append(printTopologyFromLevel(bridgesDownLevel,level+1)); return strbfr.toString(); }

Target:
public String printTopologyFromLevel(Set<Integer> bridgeIds, int level) { Set<Integer> bridgesDownLevel = new HashSet<Integer>(); StringBuffer strbfr = new StringBuffer(); strbfr.append("------level "); strbfr.append(level); strbfr.append(" -----\n"); strbfr.append("bridges on level:"); strbfr.append(bridgeIds); strbfr.append("\n"); bridgeIds.stream() .map(id -> getBridge(id)) .filter(bridge -> bridge != null) .forEach(bridge -> { strbfr.append(bridge.printTopology()); for (SharedSegment segment: getSharedSegmentOnTopologyForBridge(bridge.getId())) { if (segment.getDesignatedBridge().intValue() == bridge.getId().intValue()) { strbfr.append(segment.printTopology()); bridgesDownLevel.addAll(segment.getBridgeIdsOnSegment()); } } }); strbfr.append("------level "); strbfr.append(level); strbfr.append(" -----\n"); bridgesDownLevel.removeAll(bridgeIds); if (!bridgesDownLevel.isEmpty()) strbfr.append(printTopologyFromLevel(bridgesDownLevel,level+1)); return strbfr.toString(); }
Source:
public CSVNameSource(Reader reader) throws IOException { this.name = "Reader " + reader.toString(); this.reader = new CSVReader(reader); this.collectColumns(); }

Target:
public CSVNameSource(Reader reader) throws IOException { this.name = "Reader " + System.identityHashCode(reader); this.reader = new CSVReader(reader); this.collectColumns(); }
Source:
public Result runTestSuite() { Result result = new Result(); result.testRunStarted(); Class<? extends SPITester> testClass = getClass(); ArrayList<Method> beforeMethodList = new ArrayList<Method>(); ArrayList<Method> afterMethodList = new ArrayList<Method>(); for(Method m : testClass.getDeclaredMethods()){ if (m.isAnnotationPresent(Before.class)) { beforeMethodList.add(m); } if (m.isAnnotationPresent(After.class)) { afterMethodList.add(m); } } if(!beforeMethodList.isEmpty()) { for (Method bm : beforeMethodList) { try { bm.invoke(this, (Object[]) null); } catch (Exception e) { throw new RuntimeException(e); } } } for (Method m : testClass.getDeclaredMethods()) { if (m.isAnnotationPresent(SPITest.class)) { if (m.isAnnotationPresent(Ignore.class)) { result.testSkipped(new ResultState(testClass, m.getName(), m.getAnnotation(Ignore.class).reason())); } else try { m.invoke(this, (Object[]) null); result.testFinished(); } catch (InvocationTargetException wrappedExc) { result.testFailed(new ResultState(testClass, m.getName(), wrappedExc.getCause())); } catch (Exception e) { throw new RuntimeException(e); } finally { if (!afterMethodList.isEmpty()) { for (Method am : afterMethodList) { try { am.invoke(this, (Object[]) null); } catch (Exception e) { throw new RuntimeException(e); } } } } } } result.testRunFinished(); return result; }

Target:
public Result runTestSuite() { Result result = new Result(); result.testRunStarted(); Class<? extends SPITester> testClass = getClass(); ArrayList<Method> beforeMethodList = new ArrayList<Method>(); ArrayList<Method> afterMethodList = new ArrayList<Method>(); for(Method m : testClass.getDeclaredMethods()){ if (m.isAnnotationPresent(Before.class)) { beforeMethodList.add(m); } if (m.isAnnotationPresent(After.class)) { afterMethodList.add(m); } } for (Method m : testClass.getDeclaredMethods()) { if (m.isAnnotationPresent(SPITest.class)) { if (m.isAnnotationPresent(Ignore.class)) { result.testSkipped(new ResultState(testClass, m.getName(), m.getAnnotation(Ignore.class).reason())); } else try { for (Method bm : beforeMethodList) { try { bm.invoke(this, (Object[]) null); } catch (Exception e) { throw new RuntimeException(e); } } m.invoke(this, (Object[]) null); result.testFinished(); } catch (InvocationTargetException wrappedExc) { result.testFailed(new ResultState(testClass, m.getName(), wrappedExc.getCause())); } catch (Exception e) { throw new RuntimeException(e); } finally { if (!afterMethodList.isEmpty()) { for (Method am : afterMethodList) { try { am.invoke(this, (Object[]) null); } catch (Exception e) { throw new RuntimeException(e); } } } } } } result.testRunFinished(); return result; }
Source:
public MethodDefinition( ClassDefinition declaringClass, EnumSet<Access> access, String name, ParameterizedType returnType, Iterable<Parameter> parameters ) { int parameterCount = Iterables.size(parameters); checkArgument( parameterCount > MAX_ALLOWED_VARARG_ARGUMENTS, "Number of arguments (%d) for vararg functions exceeds limit (%d)", parameterCount, MAX_ALLOWED_VARARG_ARGUMENTS); this.declaringClass = declaringClass; body = new BytecodeBlock(); this.access = access; this.name = name; if (returnType != null) { this.returnType = returnType; } else { this.returnType = type(void.class); } this.parameters = ImmutableList.copyOf(parameters); this.parameterTypes = Lists.transform(this.parameters, Parameter::getType); this.parameterAnnotations = ImmutableList.copyOf(transform(parameters, input -> new ArrayList<>())); Optional<ParameterizedType> thisType = Optional.empty(); if (!access.contains(STATIC)) { thisType = Optional.of(declaringClass.getType()); } scope = new Scope(thisType, parameters); }

Target:
public MethodDefinition( ClassDefinition declaringClass, EnumSet<Access> access, String name, ParameterizedType returnType, Iterable<Parameter> parameters ) { checkArgument(Iterables.size(parameters) <= 254, "Too many parameters for method"); this.declaringClass = declaringClass; body = new BytecodeBlock(); this.access = access; this.name = name; if (returnType != null) { this.returnType = returnType; } else { this.returnType = type(void.class); } this.parameters = ImmutableList.copyOf(parameters); this.parameterTypes = Lists.transform(this.parameters, Parameter::getType); this.parameterAnnotations = ImmutableList.copyOf(transform(parameters, input -> new ArrayList<>())); Optional<ParameterizedType> thisType = Optional.empty(); if (!declaringClass.isInterface() && !access.contains(STATIC)) { thisType = Optional.of(declaringClass.getType()); } scope = new Scope(thisType, parameters); }
Source:
public void clickUndoSwapLink() { firstUndoLink.click(); PageObjectLogging.log("undoSwap", "undo link clicked", true); }

Target:
public void clickUndoSwapLink() { firstUndoLink.click(); PageObjectLogging.log("clickUndoSwapLink", "undo link clicked", true); }
Source:
private void updateNoUpstreamNotification() { final boolean tetheringInactive = mDownstreamTypesMask <= DOWNSTREAM_NONE; if (tetheringInactive || !mNoUpstream || setupNoUpstreamNotification() == NO_NOTIFY) { clearNotification(NO_UPSTREAM_NOTIFICATION_ID); getHandler().removeMessages(EVENT_SHOW_NO_UPSTREAM); } }

Target:
private void updateNoUpstreamNotification() { final boolean tetheringInactive = mDownstreamTypesMask == DOWNSTREAM_NONE; if (tetheringInactive || !mNoUpstream || setupNoUpstreamNotification() == NO_NOTIFY) { clearNotification(NO_UPSTREAM_NOTIFICATION_ID); mHandler.removeMessages(EVENT_SHOW_NO_UPSTREAM); } }
Source:
static HandledState newInstance(SeverityReasonType severityReason, Severity severity) { return newInstance(severityReason, null, severity, false); }

Target:
static HandledState newInstance(SeverityReasonType severityReason, Severity severity) { return newInstance(severityReason, Collections.<String, String>emptyMap(), severity, false); }
Source:
private String buildUrl(String cache, K key) { String s = new StringBuffer(buildCacheUrl(cache)).append("/").append(key).toString(); log.trace("buildUrl(String cache, K key) = " + s); return s; }

Target:
private String buildUrl(String cache, K key) { String s = new StringBuilder(buildCacheUrl(cache)).append("/").append(key).toString(); log.trace("buildUrl(String cache, K key) = " + s); return s; }
Source:
protected abstract Object visitDataReadCommand(InvocationContext ctx, DataCommand command) throws Throwable; protected abstract Object visitDataWriteCommand(InvocationContext ctx, DataWriteCommand command) throws Throwable; protected final Object visitNonTxDataWriteCommand(InvocationContext ctx, DataWriteCommand command) throws Throwable { Object key; if (hasSkipLocking(command) || ((key = command.getKey()) == ctx.getLockOwner()) || !shouldLockKey(key)) { return invokeNext(ctx, command); } try { lockAndRecord(ctx, key, getLockTimeoutMillis(command)); } catch (Throwable t) { lockManager.unlockAll(ctx); throw t; } return invokeNextAndFinally(ctx, command, unlockAllReturnHandler); }

Target:
protected abstract Object visitDataReadCommand(InvocationContext ctx, DataCommand command) throws Throwable; protected abstract Object visitDataWriteCommand(InvocationContext ctx, DataWriteCommand command) throws Throwable; protected final Object visitNonTxDataWriteCommand(InvocationContext ctx, DataWriteCommand command) throws Throwable { Object key; if (hasSkipLocking(command) || !shouldLockKey((key = command.getKey()))) { return invokeNext(ctx, command); } try { lockAndRecord(ctx, key, getLockTimeoutMillis(command)); } catch (Throwable t) { lockManager.unlockAll(ctx); throw t; } return invokeNextAndFinally(ctx, command, unlockAllReturnHandler); }
Source:
void setCountryComboBoxAction(ComboBox<Country> countryComboBox) { countryComboBox.setOnAction(e -> { selectedCountry = countryComboBox.getSelectionModel().getSelectedItem(); updateFromInputs(); }); }

Target:
void setCountryComboBoxAction(ComboBox<Country> countryComboBox) { countryComboBox.setOnAction(e -> { selectedCountry = countryComboBox.getSelectionModel().getSelectedItem(); updateFromInputs(); accountIdInputTextField.resetValidation(); accountIdInputTextField.validate(); accountIdInputTextField.requestFocus(); countryComboBox.requestFocus(); }); }
Source:
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException { final long docId = Long.parseLong(documentId); updateCurrentStorageManagerIfNeeded(docId); final FileCursor result = new FileCursor(projection); result.addFile(mCurrentStorageManager.getFileById(docId)); return result; }

Target:
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException { final long docId = Long.parseLong(documentId); updateCurrentStorageManagerIfNeeded(docId); final FileCursor result = new FileCursor(projection); if (result != null) result.addFile(mCurrentStorageManager.getFileById(docId)); return result; }
Source:
public static @NonNull String buildCompatibilityTraceTypeId(@NonNull String traceTypeId) { int index = traceTypeId.lastIndexOf(SEPARATOR); if ((index != -1) && (traceTypeId.startsWith(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX))) { String definitionName = index < traceTypeId.length() ? traceTypeId.substring(index + 1) : ""; if (traceTypeId.contains(CustomTxtTrace.class.getSimpleName() + SEPARATOR) && traceTypeId.indexOf(SEPARATOR) == index) { return buildTraceTypeId(CustomTxtTraceDefinition.CUSTOM_TXT_CATEGORY, definitionName); } return NonNullUtils.checkNotNull(traceTypeId.replace(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX, CUSTOM_TXT_TRACE_TYPE_PREFIX)); } return traceTypeId; }

Target:
public static @NonNull String buildCompatibilityTraceTypeId(@NonNull String traceTypeId) { if (traceTypeId.startsWith(EARLY_TRACE_COMPASS_CUSTOM_TXT_TRACE_TYPE_PREFIX)) { return NonNullUtils.checkNotNull(traceTypeId.replace(EARLY_TRACE_COMPASS_CUSTOM_TXT_TRACE_TYPE_PREFIX, CUSTOM_TXT_TRACE_TYPE_PREFIX)); } int index = traceTypeId.lastIndexOf(SEPARATOR); if ((index != -1) && (traceTypeId.startsWith(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX))) { String definitionName = index < traceTypeId.length() ? traceTypeId.substring(index + 1) : ""; if (traceTypeId.contains(CustomTxtTrace.class.getSimpleName() + SEPARATOR) && traceTypeId.indexOf(SEPARATOR) == index) { return buildTraceTypeId(CustomTxtTraceDefinition.CUSTOM_TXT_CATEGORY, definitionName); } return NonNullUtils.checkNotNull(traceTypeId.replace(LINUX_TOOLS_CUSTOM_TXT_TRACE_TYPE_PREFIX, CUSTOM_TXT_TRACE_TYPE_PREFIX)); } return traceTypeId; }
Source:
public String getTableName() { Queryable queryable = getQueryable(); return ( queryable != null ) ? queryable.getTableName() : "{none}"; }

Target:
private String getTableName() { Queryable queryable = getQueryable(); return ( queryable != null ) ? queryable.getTableName() : "{none}"; }
Source:
public void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String message) { if (unityAdsError == UnityAds.UnityAdsError.NOT_INITIALIZED || unityAdsError == UnityAds.UnityAdsError.INITIALIZE_FAILED || unityAdsError == UnityAds.UnityAdsError.INIT_SANITY_CHECK_FAIL || unityAdsError == UnityAds.UnityAdsError.INVALID_ARGUMENT) { for (Listener listener : mListeners) { listener.onInitializeError(message); } mListeners.clear(); UnityAds.removeListener(getInstance().getUnitySingletonListenerInstance()); } }

Target:
public void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String message) { Log.w(TAG, "UnityAds error message: " + message); if (unityAdsError.equals(UnityAds.UnityAdsError.NOT_INITIALIZED) || unityAdsError.equals(UnityAds.UnityAdsError.INITIALIZE_FAILED) || unityAdsError.equals(UnityAds.UnityAdsError.INIT_SANITY_CHECK_FAIL) || unityAdsError.equals(UnityAds.UnityAdsError.INVALID_ARGUMENT) || unityAdsError.equals(UnityAds.UnityAdsError.AD_BLOCKER_DETECTED)) { for (HashMap.Entry<String, WeakReference<UnityAdapterDelegate>> entry : mPlacementsInUse.entrySet()) { if (entry.getValue().get() != null) { entry.getValue().get().onUnityAdsError(UnityAds.UnityAdsError.NOT_INITIALIZED, entry.getValue().get().getPlacementId()); } mPlacementsInUse.remove(entry.getKey()); } } else if (mAdShowingAdapterDelegate != null) { UnityAdapterDelegate delegate = mAdShowingAdapterDelegate.get(); if (delegate != null) { delegate.onUnityAdsError(unityAdsError, delegate.getPlacementId()); } } }
Source:
public MainTableDataModel(BibDatabaseContext context) { ObservableList<BibEntry> allEntries = BindingsHelper.forUI(context.getDatabase().getEntries()); ObservableList<BibEntryTableViewModel> entriesViewModel = BindingsHelper.mapBacked(allEntries, BibEntryTableViewModel::new); entriesFiltered = new FilteredList<>(entriesViewModel); entriesFiltered.predicateProperty().bind( Bindings.createObjectBinding(() -> this::isMatched, Globals.stateManager.activeGroupProperty(), Globals.stateManager.activeSearchQueryProperty()) ); entriesFiltered.addListener((ListChangeListener<BibEntryTableViewModel>) c -> { Globals.stateManager.setSearchResultSize(entriesFiltered.size()); }); entriesSorted = new SortedList<>(entriesFiltered); }

Target:
public MainTableDataModel(BibDatabaseContext context) { ObservableList<BibEntry> allEntries = BindingsHelper.forUI(context.getDatabase().getEntries()); ObservableList<BibEntryTableViewModel> entriesViewModel = BindingsHelper.mapBacked(allEntries, BibEntryTableViewModel::new); entriesFiltered = new FilteredList<>(entriesViewModel); entriesFiltered.predicateProperty().bind( Bindings.createObjectBinding(() -> this::isMatched, Globals.stateManager.activeGroupProperty(), Globals.stateManager.activeSearchQueryProperty()) ); IntegerProperty resultSize = new SimpleIntegerProperty(); resultSize.bind(Bindings.size(entriesFiltered)); Globals.stateManager.setActiveSearchResultSize(context, resultSize); entriesSorted = new SortedList<>(entriesFiltered); }
Source:
public static String encryptPassword(String password) { String result = password; String keyFile = Config.<String> GetValue(ConfigValues.keystoreUrl, Config.DefaultConfigurationVersion); String passwd = Config.<String> GetValue(ConfigValues.keystorePass, Config.DefaultConfigurationVersion); String alias = Config.<String> GetValue(ConfigValues.CertAlias, Config.DefaultConfigurationVersion); try { result = EncryptionUtils.encrypt((String) result, keyFile, passwd, alias); } catch (Exception e) { log.errorFormat("Failed to encrpyt password, error message: {0}", e.getMessage()); throw new SecurityException(e); } return result; }

Target:
public static String encryptPassword(String password) { String result = password; String keyFile = Config.<String> GetValue(ConfigValues.keystoreUrl, Config.DefaultConfigurationVersion); String passwd = Config.<String> GetValue(ConfigValues.keystorePass, Config.DefaultConfigurationVersion); String alias = Config.<String> GetValue(ConfigValues.CertAlias, Config.DefaultConfigurationVersion); try { result = EncryptionUtils.encrypt((String) result, keyFile, passwd, alias); } catch (Exception e) { throw new SecurityException(e); } return result; }
Source:
public static ViewModelProvider.Factory provideViewModelFactory(ViewModelSubComponent.Builder subComponentBuilder) { ArrayMap<Class<? extends ViewModel>, Provider<ViewModel>> viewModelMap = new ArrayMap<>(); final ViewModelSubComponent subComp = subComponentBuilder.build(); viewModelMap.put(PluginBrowserViewModel.class, new Provider<ViewModel>() { @Override public ViewModel get() { return subComp.pluginBrowserViewModel(); } }); return new ViewModelFactory(viewModelMap); }

Target:
static ViewModelProvider.Factory provideViewModelFactory(ViewModelSubComponent.Builder subComponentBuilder) { ArrayMap<Class<? extends ViewModel>, Provider<ViewModel>> viewModelMap = new ArrayMap<>(); final ViewModelSubComponent subComp = subComponentBuilder.build(); viewModelMap.put(PluginBrowserViewModel.class, new Provider<ViewModel>() { @Override public ViewModel get() { return subComp.pluginBrowserViewModel(); } }); return new ViewModelFactory(viewModelMap); }
Source:
private PythonSensor sensor(@Nullable PythonCustomRuleRepository[] customRuleRepositories, @Nullable AnalysisWarnings analysisWarnings) { FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class); FileLinesContext fileLinesContext = mock(FileLinesContext.class); when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(fileLinesContext); CheckFactory checkFactory = new CheckFactory(activeRules); if(customRuleRepositories == null) { if (analysisWarnings == null) { return new PythonSensor(fileLinesContextFactory, checkFactory, new NoSonarFilter()); } else { return new PythonSensor(fileLinesContextFactory, checkFactory, new NoSonarFilter(), analysisWarnings); } } if (analysisWarnings == null){ return new PythonSensor(fileLinesContextFactory, checkFactory, customRuleRepositories, new NoSonarFilter()); } else { return new PythonSensor(fileLinesContextFactory, checkFactory, new NoSonarFilter(), customRuleRepositories, analysisWarnings); } }

Target:
private PythonSensor sensor(@Nullable PythonCustomRuleRepository[] customRuleRepositories, @Nullable AnalysisWarnings analysisWarnings) { FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class); FileLinesContext fileLinesContext = mock(FileLinesContext.class); when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(fileLinesContext); CheckFactory checkFactory = new CheckFactory(activeRules); if(customRuleRepositories == null) { return new PythonSensor(fileLinesContextFactory, checkFactory, new NoSonarFilter(), analysisWarnings); } return new PythonSensor(fileLinesContextFactory, checkFactory, new NoSonarFilter(), customRuleRepositories, analysisWarnings); }
Source:
private void runMoves(final String firstContextId, final String secondContextId) { String srcId = firstContextId; String destId = secondContextId; for (int i = 0; i < iterations; i++) { final long numToMove = getNumUnits(partitionManager.getRangeSet(srcId, SimpleEMTask.KEY)) / 2; LOG.info("Move data of size " + numToMove + " from " + srcId + " to " + destId); final Set<LongRange> ranges = getRangeSetToMove(srcId, destId, numToMove); for (final LongRange range : ranges) { LOG.info("- " + range + ", size: " + (range.getMaximumLong() - range.getMinimumLong() + 1)); } final TraceScope moveTraceScope = Trace.startSpan("simpleMove", Sampler.ALWAYS); try { emService.move(SimpleEMTask.KEY, ranges, srcId, destId); } finally { moveTraceScope.close(); } final String tmpContextId = srcId; srcId = destId; destId = tmpContextId; if (i != (iterations - 1)) { try { Thread.sleep(periodMillis); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }

Target:
private void runMoves(final String firstContextId, final String secondContextId) { String srcId = firstContextId; String destId = secondContextId; for (int i = 0; i < iterations; i++) { final Set<LongRange> srcRangeSet = partitionManager.getRangeSet(srcId, SimpleEMTask.KEY); final long numToMove = getNumUnits(srcRangeSet) / 2; LOG.info("Move partitions of total size " + numToMove + " from " + srcId + " to " + destId); final Set<LongRange> rangeSetToMove = getRangeSetToMove(srcId, destId, srcRangeSet, numToMove); for (final LongRange range : rangeSetToMove) { LOG.info("- " + range + ", size: " + (range.getMaximumLong() - range.getMinimumLong() + 1)); } final TraceScope moveTraceScope = Trace.startSpan("simpleMove", Sampler.ALWAYS); try { emService.move(SimpleEMTask.KEY, rangeSetToMove, srcId, destId); } finally { moveTraceScope.close(); } final String tmpContextId = srcId; srcId = destId; destId = tmpContextId; if (i != (iterations - 1)) { try { Thread.sleep(periodMillis); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }
Source:
public Optional<ImmutableZkWorker> findWorkerForTask( final ImmutableMap<String, ImmutableZkWorker> zkWorkers, final Task task ) { TreeSet<ImmutableZkWorker> sortedWorkers = Sets.newTreeSet( new Comparator<ImmutableZkWorker>() { @Override public int compare( ImmutableZkWorker zkWorker, ImmutableZkWorker zkWorker2 ) { int retVal = Ints.compare(zkWorker2.getCurrCapacityUsed(), zkWorker.getCurrCapacityUsed()); if (retVal == 0) { retVal = zkWorker.getWorker().getHost().compareTo(zkWorker2.getWorker().getHost()); } return retVal; } } ); sortedWorkers.addAll(zkWorkers.values()); final String minWorkerVer = config.getMinWorkerVersion(); for (ImmutableZkWorker zkWorker : sortedWorkers) { if (zkWorker.canRunTask(task) && zkWorker.isValidVersion(minWorkerVer)) { return Optional.of(zkWorker); } } log.debug("Worker nodes %s do not have capacity to run any more tasks!", zkWorkers.values()); return Optional.absent(); }

Target:
public Optional<ImmutableZkWorker> findWorkerForTask( final ImmutableMap<String, ImmutableZkWorker> zkWorkers, final Task task ) { TreeSet<ImmutableZkWorker> sortedWorkers = Sets.newTreeSet( new Comparator<ImmutableZkWorker>() { @Override public int compare( ImmutableZkWorker zkWorker, ImmutableZkWorker zkWorker2 ) { int retVal = Ints.compare(zkWorker2.getCurrCapacityUsed(), zkWorker.getCurrCapacityUsed()); if (retVal == 0) { retVal = zkWorker.getWorker().getHost().compareTo(zkWorker2.getWorker().getHost()); } return retVal; } } ); sortedWorkers.addAll(zkWorkers.values()); final String minWorkerVer = config.getMinWorkerVersion(); for (ImmutableZkWorker zkWorker : sortedWorkers) { if (zkWorker.canRunTask(task) && zkWorker.isValidVersion(minWorkerVer)) { return Optional.of(zkWorker); } } return Optional.absent(); }
Source:
public void submitProductiveSheet(int centerId, ProductiveCollectionSheetPayload payload) { checkViewAttached(); getMvpView().showProgressbar(true); mSubscription.add(collectionDataManager.submitProductiveSheet(centerId, payload) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Subscriber<GenericResponse>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); try { if (e instanceof HttpException) { String errorMessage = ((HttpException) e).response().errorBody() .string(); if (((HttpException) e).code() == 500) { getMvpView().showError(errorMessage); } else { getMvpView().showError(MFErrorParser.parseError(errorMessage) .getErrors().get(0).getDefaultUserMessage()); } } } catch (Throwable throwable) { RxJavaPlugins.getInstance().getErrorHandler().handleError(e); } } @Override public void onNext(GenericResponse response) { getMvpView().showProgressbar(false); getMvpView().showError(c.getResources().getString( R.string.collectionsheet_submit_success)); } })); }

Target:
public void submitProductiveSheet(int centerId, ProductiveCollectionSheetPayload payload) { checkViewAttached(); getMvpView().showProgressbar(true); mSubscription.add(collectionDataManager.submitProductiveSheet(centerId, payload) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Subscriber<GenericResponse>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); getMvpView().showError(MFErrorParser.errorMessage(e)); } @Override public void onNext(GenericResponse genericResponse) { getMvpView().showProgressbar(false); getMvpView().showError(c.getResources().getString( R.string.collectionsheet_submit_success)); } })); }
Source:
protected List querySelector(CSSRuleList ruleList, int selectorType, int selectorConditionType) { List list = new ArrayList(); int length = ruleList.getLength(); for (int i = 0; i < length; i++) { CSSRule rule = ruleList.item(i); if (rule.getType() == CSSRule.STYLE_RULE && rule instanceof ExtendedCSSRule) { ExtendedCSSRule r = (ExtendedCSSRule) rule; SelectorList selectorList = r.getSelectorList(); int l = selectorList.getLength(); for (int j = 0; j < l; j++) { Selector selector = (Selector) selectorList.item(j); if (selector.getSelectorType() == selectorType && selectorType == Selector.SAC_CONDITIONAL_SELECTOR) { ConditionalSelector conditionalSelector = (ConditionalSelector) selector; short conditionType = conditionalSelector.getCondition().getConditionType(); if (selectorConditionType == conditionType) { list.add(selector); } } } } } return list; }

Target:
protected List<Selector> querySelector(CSSRuleList ruleList, int selectorType, int selectorConditionType) { List<Selector> list = new ArrayList<Selector>(); if (selectorType == Selector.SAC_CONDITIONAL_SELECTOR) { int length = ruleList.getLength(); for (int i = 0; i < length; i++) { CSSRule rule = ruleList.item(i); if (rule.getType() == CSSRule.STYLE_RULE && rule instanceof ExtendedCSSRule) { ExtendedCSSRule r = (ExtendedCSSRule) rule; SelectorList selectorList = r.getSelectorList(); int l = selectorList.getLength(); for (int j = 0; j < l; j++) { Selector selector = (Selector) selectorList.item(j); if (selector.getSelectorType() == selectorType) { ConditionalSelector conditionalSelector = (ConditionalSelector) selector; short conditionType = conditionalSelector.getCondition().getConditionType(); if (selectorConditionType == conditionType) { list.add(selector); } } } } } } return list; }
Source:
private void processContainer(ContainerID id) { lockManager.lock(id); try { final ContainerInfo container = containerManager.getContainer(id); final Set<ContainerReplica> replicas = containerManager .getContainerReplicas(container.containerID()); final LifeCycleState state = container.getState(); if (state == LifeCycleState.OPEN) { return; } if (state == LifeCycleState.CLOSING) { replicas.forEach(replica -> sendCloseCommand( container, replica.getDatanodeDetails(), false)); return; } updateInflightAction(container, inflightReplication, action -> replicas.stream() .anyMatch(r -> r.getDatanodeDetails().equals(action.datanode))); updateInflightAction(container, inflightDeletion, action -> replicas.stream() .noneMatch(r -> r.getDatanodeDetails().equals(action.datanode))); if (state == LifeCycleState.QUASI_CLOSED) { forceCloseContainer(container, replicas); } if (isContainerHealthy(container, replicas)) { return; } if (isContainerUnderReplicated(container, replicas)) { handleUnderReplicatedContainer(container, replicas); return; } if (isContainerOverReplicated(container, replicas)) { handleOverReplicatedContainer(container, replicas); return; } handleInconsistentContainer(container, replicas); } catch (ContainerNotFoundException ex) { LOG.warn("Missing container {}.", id); } finally { lockManager.unlock(id); } }

Target:
private void processContainer(ContainerID id) { lockManager.lock(id); try { final ContainerInfo container = containerManager.getContainer(id); final Set<ContainerReplica> replicas = containerManager .getContainerReplicas(container.containerID()); final LifeCycleState state = container.getState(); if (state == LifeCycleState.OPEN) { return; } if (state == LifeCycleState.CLOSING) { replicas.forEach(replica -> sendCloseCommand( container, replica.getDatanodeDetails(), false)); return; } if (state == LifeCycleState.QUASI_CLOSED && canForceCloseContainer(container, replicas)) { forceCloseContainer(container, replicas); return; } updateInflightAction(container, inflightReplication, action -> replicas.stream() .anyMatch(r -> r.getDatanodeDetails().equals(action.datanode))); updateInflightAction(container, inflightDeletion, action -> replicas.stream() .noneMatch(r -> r.getDatanodeDetails().equals(action.datanode))); if (isContainerHealthy(container, replicas)) { return; } if (isContainerUnderReplicated(container, replicas)) { handleUnderReplicatedContainer(container, replicas); return; } if (isContainerOverReplicated(container, replicas)) { handleOverReplicatedContainer(container, replicas); return; } handleUnstableContainer(container, replicas); } catch (ContainerNotFoundException ex) { LOG.warn("Missing container {}.", id); } finally { lockManager.unlock(id); } }
Source:
public static void setConversionProperties(Configuration conf) { if (conf != null) { useEnumId = conf.getBoolean(USE_ENUM_ID_CONF_KEY, false); LOG.info("useEnumId is set to " + useEnumId); } }

Target:
public static void setConversionProperties(Configuration conf) { if (conf != null) { useEnumId = conf.getBoolean(USE_ENUM_ID_CONF_KEY, false); LOG.debug("useEnumId is set to " + useEnumId); } }
Source:
public Dataset getDataset(String datasetID) throws IOException { String path = "/datasets/" + datasetID; logInfo("Calling dataset API").addParameter("path", path).log(); try (CloseableHttpResponse response = client.sendGet(path, null, null)) { String responseString = EntityUtils.toString(response.getEntity()); return ContentUtil.deserialise(responseString, Dataset.class); } }

Target:
public Dataset getDataset(String datasetID) throws IOException, DatasetNotFoundException, UnexpectedResponseException, BadRequestException { if (StringUtils.isEmpty(datasetID)) { throw new BadRequestException("A dataset ID must be provided."); } String path = "/datasets/" + datasetID; logInfo("Calling dataset API").addParameter("path", path).log(); HttpGet httpget = new HttpGet(datasetAPIURL + path); try (CloseableHttpResponse response = client.execute(httpget)) { switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: String responseString = EntityUtils.toString(response.getEntity()); return ContentUtil.deserialise(responseString, Dataset.class); case HttpStatus.SC_NOT_FOUND: throw new DatasetNotFoundException("The dataset API returned 404 for " + path); default: throw new UnexpectedResponseException( String.format("The dataset API returned a %s response for %s", response.getStatusLine().getStatusCode(), path)); } } }
Source:
static Point[] getFillStartPoints(Point[] cellSelection) { final Map<Integer, Set<Integer>> rowToSelectedColumns = createSelectionMap(cellSelection); final Point[] result = new Point[rowToSelectedColumns.size()]; int startColumn = -1; final Set<Integer> columns = rowToSelectedColumns.values().iterator().next(); for (final Integer integer : columns) { if (startColumn == -1) { startColumn = integer; continue; } if (integer < startColumn) { startColumn = integer; } } int i = 0; for (final Integer startRow : rowToSelectedColumns.keySet()) { result[i++] = new Point(startColumn, startRow); } return result; }

Target:
static Point[] getFillStartPoints(Point[] cellSelection) { final Map<Integer, Set<Integer>> rowToSelectedColumns = createSelectionMap(cellSelection); final Point[] result = new Point[rowToSelectedColumns.size()]; final Set<Integer> columns = rowToSelectedColumns.values().iterator().next(); final int startColumn = Collections.min(columns); int i = 0; for (final Integer startRow : rowToSelectedColumns.keySet()) { result[i++] = new Point(startColumn, startRow); } return result; }
Source:
public OauthGrantAuthenticationResult authenticate(RefreshGrantRequest refreshGrantRequest) { RefreshGrantAuthenticator authenticator = RefreshGrantAuthenticators.forApplication(this, getDataStore()); return authenticator.authenticate(refreshGrantRequest); }

Target:
public OauthGrantAuthenticationResult authenticate(RefreshGrantRequest refreshGrantRequest) { Assert.notNull(refreshGrantRequest, "refreshGrantRequest is required and cannot be null."); RefreshGrantAuthenticator authenticator = RefreshGrantAuthenticators.forApplication(this, getDataStore()); return authenticator.authenticate(refreshGrantRequest); }
Source:
private void addReward(Block block) { BigInteger totalBlockReward = BLOCK_REWARD; if (block.getUncleList().size() > 0) { for (BlockHeader uncle : block.getUncleList()) { track.addBalance(uncle.getCoinbase(), new BigDecimal(BLOCK_REWARD).multiply(BigDecimal.valueOf(8 + uncle.getNumber() - block.getNumber()).divide(new BigDecimal(8), RoundingMode.HALF_UP)).toBigInteger()); totalBlockReward = totalBlockReward.add(INCLUSION_REWARD); } } track.addBalance(block.getCoinbase(), totalBlockReward); }

Target:
private void addReward(Block block) { BigInteger standardTotalBlockReward = BLOCK_REWARD; if (block.getUncleList().size() > 0) { for (BlockHeader uncle : block.getUncleList()) { track.addBalance( uncle.getCoinbase(), BLOCK_REWARD.multiply(BigInteger.valueOf(MAGIC_REWARD_OFFSET + uncle.getNumber() - block.getNumber())).divide(BigInteger.valueOf(MAGIC_REWARD_OFFSET)) ); standardTotalBlockReward = standardTotalBlockReward.add(INCLUSION_REWARD); } } track.addBalance(block.getCoinbase(), standardTotalBlockReward); }
Source:
public void testSimpleGetAllWithLoader() throws Exception { when(cacheLoader.loadAll((Iterable)any())).thenAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Iterable<Integer> iterable = (Iterable) invocation.getArguments()[0]; Map<Number, CharSequence> result = new HashMap<Number, CharSequence>(); for (Integer i : iterable) { switch (i) { case 1: result.put(1, "one"); break; case 2: result.put(2, "two"); break; case 3: result.put(3, null); break; default: throw new AssertionError("Should not try to load key " + i); } } return result; } }); Map<Number, CharSequence> all = testCache.getAll(Arrays.asList(1, 2, 3)); assertThat(all.size(), is(2)); assertThat(all.get(1), Matchers.<CharSequence>equalTo("one")); assertThat(all.get(2), Matchers.<CharSequence>equalTo("two")); assertThat(all.get(3), is(Matchers.nullValue())); }

Target:
public void testSimpleGetAllWithLoader() throws Exception { when(cacheLoader.loadAll((Iterable)any())).thenAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Iterable<Integer> iterable = (Iterable) invocation.getArguments()[0]; Map<Number, CharSequence> result = new HashMap<Number, CharSequence>(); for (Integer i : iterable) { switch (i) { case 1: result.put(1, "one"); break; case 2: result.put(2, "two"); break; case 3: result.put(3, null); break; default: throw new AssertionError("Should not try to load key " + i); } } return result; } }); Map<Number, CharSequence> all = testCache.getAll(Arrays.asList(1, 2, 3)); assertThat(all.keySet(), containsInAnyOrder((Number)1, 2)); assertThat(all.get(1), Matchers.<CharSequence>equalTo("one")); assertThat(all.get(2), Matchers.<CharSequence>equalTo("two")); }
Source:
public void expunge_whenChargeMeetsTheConditions() { ChargeEntity chargeEntity = aWebChargeEntity() .withGatewayAccount(aGatewayAccountEntity().withId(1L).build()) .withAmount(120L) .build(); chargeEntity.setStatus(ChargeStatus.CREATED); chargeEntity.setStatus(ChargeStatus.ENTERING_CARD_DETAILS); chargeEntity.setStatus(ChargeStatus.AUTHORISATION_READY); chargeEntity.setStatus(ChargeStatus.AUTHORISATION_SUCCESS); chargeEntity.setStatus(ChargeStatus.CAPTURE_READY); chargeEntity.setStatus(ChargeStatus.CAPTURE_SUBMITTED); when(mockExpungeConfig.isExpungeChargesEnabled()).thenReturn(true); when(mockExpungeConfig.getMinimumAgeOfChargeInDays()).thenReturn(minimumAgeOfChargeInDays); when(mockChargeDao.findChargeToExpunge(minimumAgeOfChargeInDays, defaultExcludeChargesParityCheckedWithInDays)) .thenReturn(Optional.of(chargeEntity)); when(parityCheckService.parityCheckChargeForExpunger(chargeEntity)).thenReturn(true); chargeExpungeService.expunge(2); }

Target:
public void expunge_whenChargeMeetsTheConditions() { ChargeEntity chargeEntity = ChargeEntityFixture.aValidChargeEntity() .withGatewayAccountEntity(aGatewayAccountEntity().withId(1L).build()) .withAmount(120L) .withStatus(ChargeStatus.CAPTURED) .build(); when(mockExpungeConfig.isExpungeChargesEnabled()).thenReturn(true); when(mockExpungeConfig.getMinimumAgeOfChargeInDays()).thenReturn(minimumAgeOfChargeInDays); when(mockChargeDao.findChargeToExpunge(minimumAgeOfChargeInDays, defaultExcludeChargesParityCheckedWithInDays)) .thenReturn(Optional.of(chargeEntity)).thenReturn(Optional.empty()); when(parityCheckService.parityCheckChargeForExpunger(chargeEntity)).thenReturn(true); chargeExpungeService.expunge(2); verify(mockChargeDao).expungeCharge(chargeEntity.getId()); }
Source:
public void mouseHover(MouseEvent e) { if (getChartViewer().getWindowDuration() != 0) { IAxis xAxis = getChart().getAxisSet().getXAxis(0); double xCoordinate = xAxis.getDataCoordinate(e.x); ISeries[] series = getChart().getSeriesSet().getSeries(); if ((xCoordinate < 0) || (series.length == 0)) { return; } double[] xS = series[0].getXSeries(); if (xS == null) { return; } int index = 0; for (int i = 0; i < xS.length; i++) { if (xS[i] > xCoordinate) { break; } index = i; } Format format = getChart().getAxisSet().getYAxis(0).getTick().getFormat(); if (format == null) { format = DEFAULT_FORMAT; } StringBuilder buffer = new StringBuilder(); try (Formatter formatter = new Formatter(buffer, Locale.US);) { formatter.format("%8s\t%12s%n", "Time", TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()).toString()); } for (ISeries serie : series) { double[] yS = serie.getYSeries(); if (yS == null || yS.length <= index || !serie.isVisible()) { continue; } try (Formatter formatter = new Formatter(buffer, Locale.US);) { formatter.format("%8s\t%12s%n", serie.getId(), format.format(yS[index])); } } getChart().getPlotArea().setToolTipText(buffer.toString()); getChart().redraw(); } }

Target:
public void mouseHover(MouseEvent e) { if (getChartViewer().getWindowDuration() != 0) { IAxis xAxis = getChart().getAxisSet().getXAxis(0); double xCoordinate = xAxis.getDataCoordinate(e.x); ISeries[] series = getChart().getSeriesSet().getSeries(); if ((xCoordinate < 0) || (series.length == 0)) { return; } double[] xS = series[0].getXSeries(); if (xS == null) { return; } int index = 0; for (int i = 0; i < xS.length; i++) { if (xS[i] > xCoordinate) { break; } index = i; } Format format = getChart().getAxisSet().getYAxis(0).getTick().getFormat(); if (format == null) { format = DEFAULT_FORMAT; } StringBuilder buffer = new StringBuilder(); try (Formatter formatter = new Formatter(buffer, Locale.US);) { formatter.format(TWO_COLUMN_TOOLTIP_LINE, Messages.TmfCommonXLineChartTooltipProvider_time, TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()).toString()); } for (ISeries serie : series) { double[] yS = serie.getYSeries(); if (yS == null || yS.length <= index || !serie.isVisible()) { continue; } try (Formatter formatter = new Formatter(buffer, Locale.US);) { formatter.format(TWO_COLUMN_TOOLTIP_LINE, serie.getId(), format.format(yS[index])); } } getChart().getPlotArea().setToolTipText(buffer.toString()); getChart().redraw(); } }