auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void initWithContext(@NonNull Context context) { logger.verbose("initWithContext(context) called!"); if (context == null) { Log(LOG_LEVEL.WARN, "context is null, ignoring!"); return; } boolean wasAppContextNull = (appContext == null); appContext = context.getApplicationContext(); <START> if (context instanceof Activity) <END> appActivity = new WeakReference<>((Activity) context); setupActivityLifecycleListener(wasAppContextNull); setupPrivacyConsent(appContext); logger.verbose("initWithContext(context) finished, checking if appId has been set before proceeding..."); if (appId == null) { String oldAppId = getSavedAppId(); if (oldAppId == null) { logger.warning("appContext set, but please call setAppId(appId) with a valid appId to complete OneSignal init!"); } else { logger.verbose("appContext set and an old appId was found, attempting to call setAppId(oldAppId)"); setAppId(oldAppId); } return; } logger.verbose("initWithContext(context) successful and appId is set, continuing OneSignal init..."); init(context); }</code><technical_language>nit, extra space instanceof</technical_language>

Target:
public static void initWithContext(@NonNull Context context) { if (context == null) { logger.warning("initWithContext called with null context, ignoring!"); return; } boolean wasAppContextNull = (appContext == null); appContext = context.getApplicationContext(); if (context instanceof Activity) appActivity = new WeakReference<>((Activity) context); setupActivityLifecycleListener(wasAppContextNull); setupPrivacyConsent(appContext); if (appId == null) { String oldAppId = getSavedAppId(); if (oldAppId == null) { logger.warning("appContext set, but please call setAppId(appId) with a valid appId to complete OneSignal init!"); } else { logger.verbose("appContext set and cached app id found, calling setAppId with: " + oldAppId); setAppId(oldAppId); } return; } else { logger.verbose("initWithContext called with: " + context); } init(context); }
Source:
<code>public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> parameters, List<String> messages) { if (StringUtils.isNotEmpty(vm.getCpuName())) { List<VDS> hostsToRunOn = new ArrayList<VDS>(); for (VDS host : hosts) { int compareResult = CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), host.getCpuName().getCpuName(), vm.getVdsGroupCompatibilityVersion()); if (compareResult >= 0) { hostsToRunOn.add(host); } else { <START> messages.add(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL.toString()); <END> log.debugFormat("Host {0} has CPU level ({1}) which is lower than the CPU level the VM was run with ({2})", host.getName(), host.getCpuName(), vm.getCpuName()); } } return hostsToRunOn; } else { return hosts; } }</code><technical_language>This add a message host. if 100 hosts 2 fine, get 98 messages. collect failed hosts message? Also, please check Martin Sivak collect filtered-out hosts, resources present informative message filter</technical_language>

Target:
public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> parameters, List<String> messages) { boolean filteredOutHosts = false; if (StringUtils.isNotEmpty(vm.getCpuName())) { List<VDS> hostsToRunOn = new ArrayList<VDS>(); for (VDS host : hosts) { String hostCpuName = CpuFlagsManagerHandler.FindMaxServerCpuByFlags(host.getCpuFlags(), host.getVdsGroupCompatibilityVersion()).getCpuName(); int compareResult = CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), hostCpuName, vm.getVdsGroupCompatibilityVersion()); if (compareResult <= 0) { hostsToRunOn.add(host); log.debugFormat("Host {0} wasn't filtered out as it has a CPU level ({1}) which is higher or equal than the CPU level the VM was run with ({2})", host.getName(), hostCpuName, vm.getCpuName()); } else { log.debugFormat("Host {0} was filtered out as it has a CPU level ({1}) which is lower than the CPU level the VM was run with ({2})", host.getName(), hostCpuName, vm.getCpuName()); filteredOutHosts = true; } } if (filteredOutHosts) { messages.add(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL.toString()); } return hostsToRunOn; } else { return hosts; } }
Source:
<code>public void testgetStreamWithPhysicalNameInConfig() { Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME, StreamConfig.SYSTEM(), TEST_SYSTEM); <START> AbstractApplicationRunner env = new TestAbstractApplicationRunnerImpl(config); <END> StreamSpec spec = env.getStream(STREAM_ID); assertEquals(TEST_PHYSICAL_NAME, spec.getPhysicalName()); }</code><technical_language>nit: rename runner</technical_language>

Target:
public void testgetStreamWithPhysicalNameInConfig() { Config config = buildStreamConfig(STREAM_ID, StreamConfig.PHYSICAL_NAME(), TEST_PHYSICAL_NAME, StreamConfig.SYSTEM(), TEST_SYSTEM); AbstractApplicationRunner runner = new TestAbstractApplicationRunnerImpl(config); StreamSpec spec = runner.getStream(STREAM_ID); assertEquals(TEST_PHYSICAL_NAME, spec.getPhysicalName()); }
Source:
<code>public void testSyncProcessorMetrics() { SyncRequestProcessor syncProcessor = new SyncRequestProcessor(zks, null); for (int i=0; i<500; i++) { syncProcessor.processRequest(createRquest(1, i)); } Map<String, Object> values = ServerMetrics.getAllValues(); Assert.assertEquals(500L, values.get("sync_processor_request_queued")); syncProcessor.start(); try { Thread.sleep(500); <START> } catch (Exception e){ <END> } values = ServerMetrics.getAllValues(); Assert.assertEquals(502L, values.get("cnt_sync_processor_queue_size")); Assert.assertEquals(500L, values.get("max_sync_processor_queue_size")); Assert.assertEquals(0L, values.get("min_sync_processor_queue_size")); Assert.assertEquals(500L, values.get("cnt_sync_processor_real_queue_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_real_queue_time_ms"), greaterThan(0L)); Assert.assertEquals(500L, values.get("cnt_sync_process_time")); Assert.assertThat((long)values.get("max_sync_process_time"), greaterThan(0L)); Assert.assertEquals(1L, values.get("cnt_sync_processor_queue_flush_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_queue_flush_time_ms"), greaterThanOrEqualTo(100L)); Assert.assertEquals(500L, values.get("cnt_sync_processor_queue_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_queue_time_ms"), greaterThanOrEqualTo(100L)); }</code><technical_language>Why? If get test fail, a big deal</technical_language>

Target:
public void testSyncProcessorMetrics() throws Exception{ SyncRequestProcessor syncProcessor = new SyncRequestProcessor(zks, nextProcessor); for (int i=0; i<500; i++) { syncProcessor.processRequest(createRquest(1, i)); } Map<String, Object> values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(500L, values.get("sync_processor_request_queued")); allRequestsFlushed = new CountDownLatch(500); syncProcessor.start(); allRequestsFlushed.await(5000, TimeUnit.MILLISECONDS); values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(501L, values.get("cnt_sync_processor_queue_size")); Assert.assertEquals(500L, values.get("max_sync_processor_queue_size")); Assert.assertEquals(0L, values.get("min_sync_processor_queue_size")); Assert.assertEquals(500L, values.get("cnt_sync_processor_queue_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_queue_time_ms"), greaterThan(0L)); Assert.assertEquals(500L, values.get("cnt_sync_processor_queue_and_flush_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_queue_and_flush_time_ms"), greaterThan(0L)); Assert.assertEquals(500L, values.get("cnt_sync_process_time")); Assert.assertThat((long)values.get("max_sync_process_time"), greaterThan(0L)); Assert.assertEquals(500L, values.get("max_sync_processor_batch_size")); Assert.assertEquals(1L, values.get("cnt_sync_processor_queue_flush_time_ms")); Assert.assertThat((long)values.get("max_sync_processor_queue_flush_time_ms"), greaterThanOrEqualTo(100L)); syncProcessor.shutdown(); }
Source:
<code><START> private void handleInstallMessage(Object arg) { <END> installed.set(configureNativeComponents()); }</code><technical_language>parameter is for this method removed</technical_language>

Target:
private void handleInstallMessage(Object arg) { lock.lock(); try { if (installed.get()) { warn("Received duplicate setup message with arg: " + arg); return; } String reportPath = reportDirectory + UUID.randomUUID().toString() + ".crash"; install(reportPath, true, Build.VERSION.SDK_INT); installed.set(true); } finally { lock.unlock(); } }
Source:
<code>public void retryableConfigurationDefaultTest() throws Exception { doTestHttpClient(new Runnable() { @Override public void run() { <START> final HttpRequestRetryHandler handler = getCurrentHttpClient(); <END> assertNotNull( handler ); assertThat( handler, instanceOf( DefaultHttpRequestRetryHandler.class ) ); final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler); assertEquals( 3, impl.getRetryCount() ); assertFalse( impl.isRequestSentRetryEnabled() ); } }); }</code><technical_language>is weird getCurrentHttpClient() return a client actually</technical_language>

Target:
public void retryableConfigurationDefaultTest() throws Exception { doTestHttpClient( new Runnable() { @Override public void run() { final HttpRequestRetryHandler handler = getCurrentHandler(); assertNotNull( handler ); assertThat( handler, instanceOf( DefaultHttpRequestRetryHandler.class ) ); final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler); assertEquals( 3, impl.getRetryCount() ); assertFalse( impl.isRequestSentRetryEnabled() ); } }); }
Source:
<code>private void audit() { try { GerritCall call = currentCall.get(); Audit note = (Audit) call.getMethod().getAnnotation(Audit.class); if (note != null) { <START> final Gson gson = createGsonBuilder() <END> .setDateFormat(DateFormat.LONG) .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) .setVersion(1.0) .create(); final String sid = call.getWebSession().getToken(); final String username = extractUsername(call); final List<Object> args = extractParams(note, call, gson); final String what = extractWhat(note, call.getMethod().getName()); final Object result = call.getResult(); audit.dispatch(new AuditEvent(sid, username, what, call.getWhen(), args, result)); } } catch (Throwable all) { LOG.error("Unable to log the call", all); } }</code><technical_language>Gson instances thread safe reused threads</technical_language>

Target:
private void audit() { try { GerritCall call = currentCall.get(); Audit note = (Audit) call.getMethod().getAnnotation(Audit.class); if (note != null) { final String sid = call.getWebSession().getToken(); final CurrentUser username = call.getWebSession().getCurrentUser(); final List<Object> args = extractParams(note, call, auditGson); final String what = extractWhat(note, call.getMethod().getName()); final Object result = call.getResult(); audit.dispatch(new AuditEvent(sid, username, what, call.getWhen(), args, result)); } } catch (Throwable all) { log.error("Unable to log the call", all); } }
Source:
<code>public void done() { if (external != null) { addRowsToDisk(); } else { if (isAnyDistinct()) { rows = distinctRows.values(); } if (sort != null) { if (offset > 0 || limit > 0) { <START> sort.sort(rows, offset, limit < 0 || withTies ? rows.size() : limit); <END> } else { sort.sort(rows); } } } applyOffsetAndLimit(); reset(); }</code><technical_language>this check part of if statement previous line limit < 0 in combination limit > 0 previous line dodgy</technical_language>

Target:
public void done() { if (external != null) { addRowsToDisk(); } else { if (isAnyDistinct()) { rows = distinctRows.values(); } if (sort != null && limit != 0) { boolean withLimit = limit > 0 && !withTies; if (offset > 0 || withLimit) { sort.sort(rows, offset, withLimit ? limit : rows.size()); } else { sort.sort(rows); } } } applyOffsetAndLimit(); reset(); }
Source:
<code>public static Block serializeObject(Type type, BlockBuilder builder, Object object) { if (ROW.equals(type.getTypeSignature().getBase())) { return serializeStruct(type, builder, object); } <START> else if (MAP.equals(type.getTypeSignature().getBase()) || ARRAY.equals(type.getTypeSignature().getBase())) { <END> throw new RuntimeException("Type not supported in Elasticsearch: " + type.getDisplayName()); } else { serializePrimitive(type, builder, object); return null; } }</code><technical_language>elses unnecessary</technical_language>

Target:
public static Block serializeObject(Type type, BlockBuilder builder, Object object) { if (ROW.equals(type.getTypeSignature().getBase())) { return serializeStruct(type, builder, object); } if (MAP.equals(type.getTypeSignature().getBase()) || ARRAY.equals(type.getTypeSignature().getBase())) { throw new IllegalArgumentException("Type not supported: " + type.getDisplayName()); } serializePrimitive(type, builder, object); return null; }
Source:
<code>int maybeCommitActiveTasksPerUserRequested() { <START> if (!rebalanceInProgress) { <END> return active.maybeCommitPerUserRequested(); } return -1; }</code><technical_language>nit: Ternary operator easier use</technical_language>

Target:
int maybeCommitActiveTasksPerUserRequested() { return rebalanceInProgress ? -1 : active.maybeCommitPerUserRequested(); }
Source:
<code>public VenusGlobalNavPageObject clickWikiaLogo() { wikiaLogo.click(); <START> return this; <END> }</code><technical_language>click logo redirects anther location, return VensuGlobalNavPageObject</technical_language>

Target:
public HomePageObject clickWikiaLogo() { String environment = ConfigurationFactory.getConfig().getEnv(); if (!environment.equals("prod") && !environment.contains("dev")) { WebDriverWait wait = new WebDriverWait(driver, 5); wait.until( CommonExpectedConditions.valueToBePresentInElementsAttribute(wikiaLogo, "href", environment) ); } wikiaLogo.click(); return new HomePageObject(driver); }
Source:
<code>public List<StorageServerConnections> getAllForDomain(Guid domainId) { <START> return getCallsHandler().executeReadList("GetStorageServerConnectionsOfDomain",mapper, <END> getCustomMapSqlParameterSource().addValue("storage_domain_id", domainId)); }</code><technical_language>replace Of For</technical_language>

Target:
public List<StorageServerConnections> getAllForDomain(Guid domainId) { return getCallsHandler().executeReadList("GetStorageServerConnectionsForDomain",mapper, getCustomMapSqlParameterSource().addValue("storage_domain_id", domainId)); }
Source:
<code>public Function<@NonNull ISegment, @Nullable Long> getMapper() { <START> return (o) -> { <END> return o.getStart(); }; }</code><technical_language>for short, do return o -> o;</technical_language>

Target:
public Function<@NonNull ISegment, @Nullable Long> getMapper() { return o -> o.getStart(); }
Source:
<code><START> public long getOrderItemId() { <END> return orderItemId; }</code><technical_language>add empty line methods</technical_language>

Target:
public long getOrderItemId() { return mOrderItemId; }
Source:
<code>public boolean onKeyUp(int keyCode, KeyEvent event) { Intent serviceIntent = new Intent(this, PlaybackService.class); serviceIntent.putExtra(MediaButtonReceiver.EXTRA_HARDWAREBUTTON, true); AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); Integer customKeyCode = null; switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_SPACE: customKeyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case KeyEvent.KEYCODE_DPAD_LEFT: customKeyCode = KeyEvent.KEYCODE_MEDIA_REWIND; break; case KeyEvent.KEYCODE_DPAD_RIGHT: customKeyCode = KeyEvent.KEYCODE_MEDIA_FAST_FORWARD; break; case KeyEvent.KEYCODE_M: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_TOGGLE_MUTE, 0); } else { if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) == 0) { audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); } else { audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); } } break; case KeyEvent.KEYCODE_DPAD_UP: audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); break; case KeyEvent.KEYCODE_DPAD_DOWN: audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); break; default: return super.onKeyUp(keyCode, event); } if (customKeyCode != null) { serviceIntent.putExtra(MediaButtonReceiver.EXTRA_KEYCODE, customKeyCode); <START> ContextCompat.startForegroundService(this, serviceIntent); <END> } return true; }</code><technical_language>media button receiver is a service. I try a broadcast instead. I a method is called "sendLocalBroadcast" that</technical_language>

Target:
public boolean onKeyUp(int keyCode, KeyEvent event) { AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); Integer customKeyCode = null; switch (keyCode) { case KeyEvent.KEYCODE_P: customKeyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case KeyEvent.KEYCODE_J: case KeyEvent.KEYCODE_A: case KeyEvent.KEYCODE_COMMA: customKeyCode = KeyEvent.KEYCODE_MEDIA_REWIND; break; case KeyEvent.KEYCODE_K: case KeyEvent.KEYCODE_D: case KeyEvent.KEYCODE_PERIOD: customKeyCode = KeyEvent.KEYCODE_MEDIA_FAST_FORWARD; break; case KeyEvent.KEYCODE_PLUS: case KeyEvent.KEYCODE_W: audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_MINUS: case KeyEvent.KEYCODE_S: audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_M: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_TOGGLE_MUTE, AudioManager.FLAG_SHOW_UI); return true; } break; } if (customKeyCode != null) { Intent intent = new Intent(this, PlaybackService.class); intent.putExtra(MediaButtonReceiver.EXTRA_KEYCODE, customKeyCode); ContextCompat.startForegroundService(this, intent); return true; } return super.onKeyUp(keyCode, event); }
Source:
<code>ProjectOwnerGroupsProvider(@GerritServerConfig final Config config, SchemaFactory<ReviewDb> db, @ProjectCreatorGroups Set<AccountGroup.Id> creatorGroups) { String[] ownerGroupNames = config.getStringList("repository", "*", "ownerGroup"); Set<AccountGroup.Id> ownerGroups = ConfigUtil.groupsFor(db, ownerGroupNames, log); <START> if (ownerGroups.isEmpty()){ <END> groupIds = creatorGroups; }else{ groupIds = ownerGroups; } }</code><technical_language>Style-nit: Space {</technical_language>

Target:
ProjectOwnerGroupsProvider(@GerritServerConfig final Config config, SchemaFactory<ReviewDb> db, @ProjectCreatorGroups Set<AccountGroup.Id> creatorGroups) { String[] names = config.getStringList("repository", "*", "ownerGroup"); Set<AccountGroup.Id> ownerGroups = ConfigUtil.groupsFor(db, names, log); if (ownerGroups.isEmpty()) { groupIds = creatorGroups; } else { groupIds = ownerGroups; } }
Source:
<code>private boolean isInWorkingSet(IResource resource) { if (wSetResources == null) { computeWorkingSetResources(); } for (IResource <START> setResource : <END> wSetResources) { if(setResource.getFullPath().isPrefixOf(resource.getFullPath())){ return true; } } return false; }</code><technical_language>rename 'wSetResource' (wSet ^= working set)</technical_language>

Target:
private boolean isInWorkingSet(IResource resource) { if (wSetResources == null) { computeWorkingSetResources(); } for (IResource wSetResource : wSetResources) { if(wSetResource.getFullPath().isPrefixOf(resource.getFullPath())){ return true; } } return false; }
Source:
<code>protected void fallbackOnDefaultCache() { CacheService cacheService = Framework.getService(CacheService.class); if (cacheService != null) { if (descriptor.cacheEntryName == null) { cache.setEntryCacheName("cache-" + getName()); <START> cacheService.registerCache("cache-" + getName()); <END> } if (descriptor.cacheEntryWithoutReferencesName == null) { cache.setEntryCacheWithoutReferencesName("cacheWithoutReference-" + getName()); cacheService.registerCache("cacheWithoutReference-" + getName()); } } }</code><technical_language>Put "cache-" + getName() in a local variable avoid repetition</technical_language>

Target:
protected void fallbackOnDefaultCache() { CacheService cacheService = Framework.getService(CacheService.class); if (cacheService != null) { if (descriptor.cacheEntryName == null) { String cacheEntryName = "cache-" + getName(); cache.setEntryCacheName(cacheEntryName); cacheService.registerCache(cacheEntryName); } if (descriptor.cacheEntryWithoutReferencesName == null) { String cacheEntryWithoutReferencesName = "cacheWithoutReference-" + getName(); cache.setEntryCacheWithoutReferencesName(cacheEntryWithoutReferencesName); cacheService.registerCache(cacheEntryWithoutReferencesName); } } }
Source:
<code>public int fill(final FluidStack resource, final boolean doFill) { if (resource == null) return 0; if (resource.amount <= 0) return 0; <START> if (!matchesFilter(resource)) <END> return 0; int ret = super.fill(resource, doFill); if (ret != 0 && updateCallback != null) updateCallback.accept(this); return ret; }</code><technical_language>This is unnecessary, called canFillFluidType() in super.fill()</technical_language>

Target:
public int fill(final FluidStack resource, final boolean doFill) { if (resource == null) return 0; if (resource.amount <= 0) return 0; int ret = super.fill(resource, doFill); if (ret != 0 && updateCallback != null) updateCallback.accept(this); return ret; }
Source:
<code>public void testAboveKInstance() throws Exception { <START> verifyRoundtrip("{\"type\":\"abovek\",\"k\":0.0,\"inner\":{\"type\":\"EmptyInstance\"}}", <END> new AboveKInstance(0), AboveKInstance.class); }</code><technical_language>is implementation detail of aggregations part of API. This a getter is generated for field in FilterAggregation, avoid this in ways: 1. a private static final field. 2. Annotated field @Getter(AccessLevel.NONE) go, is stateless. named a constant in uppercase</technical_language>

Target:
public void testAboveKInstance() throws Exception { verifyRoundtrip("{\"type\":\"abovek\",\"k\":0.0}", new AboveKInstance(0), AboveKInstance.class); }
Source:
<code>private ContextMenu createTabContextMenu(KeyBindingRepository keyBindingRepository) { ContextMenu contextMenu = new ContextMenu(); ActionFactory factory = new ActionFactory(keyBindingRepository); contextMenu.getItems().addAll( factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction()), factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES, new CloseOthersDatabaseAction()), factory.createMenuItem(StandardActions.CLOSE_ALL_LIBRARIES, new CloseAllDatabaseAction()), new SeparatorMenuItem(), factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, stateManager)), <START> factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this, stateManager)) <END> ); return contextMenu; }</code><technical_language>I add "Manage cite key pattern". important concerned library</technical_language>

Target:
private ContextMenu createTabContextMenu(KeyBindingRepository keyBindingRepository) { ContextMenu contextMenu = new ContextMenu(); ActionFactory factory = new ActionFactory(keyBindingRepository); contextMenu.getItems().addAll( factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction()), factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES, new CloseOthersDatabaseAction()), factory.createMenuItem(StandardActions.CLOSE_ALL_LIBRARIES, new CloseAllDatabaseAction()), new SeparatorMenuItem(), factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder()), factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(stateManager)) ); return contextMenu; }
Source:
<code>private void setupAndDropAndCreateIndex() { setupHelper.start() .withIndex( INDEX_NAME, ctx -> { IndexSchemaElement root = ctx.getSchemaElement(); root.field( "field", f -> f.asString() ) .toReference(); }, indexManager -> this.indexManager = indexManager ) .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> { } ) .setup(); Futures.unwrappedExceptionJoin( <START> ElasticsearchIndexSchemaManagerOperation.DROP_AND_CREATE.apply( indexManager.getSchemaManager() ) <END> ); }</code><technical_language>java indexManager.getSchemaManager().dropAndCreate() similarly do in ElasticsearchIndexSchemaManagerDropIfExistingIT.java</technical_language>

Target:
private void setupAndDropAndCreateIndex() { setupHelper.start() .withIndex( INDEX_NAME, ctx -> { IndexSchemaElement root = ctx.getSchemaElement(); root.field( "field", f -> f.asString() ) .toReference(); }, indexManager -> this.indexManager = indexManager ) .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> { } ) .setup(); Futures.unwrappedExceptionJoin( indexManager.getSchemaManager().dropAndCreate() ); }
Source:
<code><START> private synchronized boolean isInDateFormat(String dateString, DateFormat dateFormat) { <END> try { dateFormat.parse(dateString); return true; } catch (ParseException e) { return false; } }</code><technical_language>synchronized removed</technical_language>

Target:
private boolean isInDateFormat(String dateString, DateFormat dateFormat) { try { dateFormat.parse(dateString); return true; } catch (ParseException e) { return false; } }
Source:
<code>public TDClient createClient(SystemDefaultConfig systemDefaultConfig, Map<String, String> env, Config params, SecretProvider secrets) { <START> logger.info("YY createClient called"); <END> return clientFromConfig(systemDefaultConfig, env, params, secrets); }</code><technical_language>minor: please remove debug message</technical_language>

Target:
public TDClient createClient(SystemDefaultConfig systemDefaultConfig, Map<String, String> env, Config params, SecretProvider secrets) { return clientFromConfig(systemDefaultConfig, env, params, secrets); }
Source:
<code>public static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, boolean isRetry) { final Parameters params = new Parameters("cache_id", cache.getGeocode()); params.add("type", logType.type); params.add("log", log); params.add("date", LOG_DATE_FORMAT.format(date.getTime())); final String uri = "<LINK_0>"; final HttpResponse response = Network.postRequest(uri, params); if (response == null) { return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); } if (!isRetry && response.getStatusLine().getStatusCode() == 403) { if (ECLogin.login() == StatusCode.NO_ERROR) { apiRequest(uri, params, true); } } if (response.getStatusLine().getStatusCode() != 200) { return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); } final String data = Network.getResponseDataAlways(response); <START> if (data != null && !StringUtils.isBlank(data) && StringUtils.contains(data, "success")) { <END> final String uid = StringUtils.remove(data, "success:"); return new LogResult(StatusCode.NO_ERROR, uid); } return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); }</code><technical_language>StringUtils methods null safe. leave in front of StringUtils.contains</technical_language>

Target:
public static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, boolean isRetry) { final Parameters params = new Parameters("cache_id", cache.getGeocode()); params.add("type", logType.type); params.add("log", log); params.add("date", LOG_DATE_FORMAT.format(date.getTime())); final String uri = API_HOST + "log.php"; final HttpResponse response = Network.postRequest(uri, params); if (response == null) { return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); } if (!isRetry && response.getStatusLine().getStatusCode() == 403) { if (ECLogin.login() == StatusCode.NO_ERROR) { apiRequest(uri, params, true); } } if (response.getStatusLine().getStatusCode() != 200) { return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); } final String data = Network.getResponseDataAlways(response); if (!StringUtils.isBlank(data) && StringUtils.contains(data, "success")) { final String uid = StringUtils.remove(data, "success:"); return new LogResult(StatusCode.NO_ERROR, uid); } return new LogResult(StatusCode.LOG_POST_ERROR_EC, ""); }
Source:
<code>protected void rotate() { for (RotatingMap map : spoutTasksToRotatingMap.values()) { map.rotate(); } <START> looper.registerTimerEvent(rotateInterval, this::rotate); <END> }</code><technical_language>Runnable() wrapper</technical_language>

Target:
protected void rotate() { for (RotatingMap map : spoutTasksToRotatingMap.values()) { map.rotate(); } Runnable r = new Runnable() { @Override public void run() { rotate(); } }; looper.registerTimerEvent(rotateInterval, r); }
Source:
<code>protected void run(RegistrationClient regClient) throws Exception { List<BookieSocketAddress> bookies = Lists.newArrayList(); if (readwrite) { bookies.addAll( result( regClient.getWritableBookies() ).getValue() ); <START> bookies.addAll( <END> result( regClient.getReadOnlyBookies() ).getValue() ); } else if (readonly) { bookies.addAll( result( regClient.getReadOnlyBookies() ).getValue() ); } for (BookieSocketAddress b : bookies) { System.out.println(getBookieSocketAddrStringRepresentation(b)); } if (bookies.isEmpty()) { System.err.println("No bookie exists!"); } }</code><technical_language>in previous code reporting readwrite bookies in this case</technical_language>

Target:
protected void run(RegistrationClient regClient) throws Exception { if (!readwrite && !readonly) { readwrite = true; readonly = true; } boolean hasBookies = false; if (readwrite) { Set<BookieSocketAddress> bookies = result( regClient.getWritableBookies() ).getValue(); if (!bookies.isEmpty()) { System.out.println("ReadWrite Bookies :"); printBookies(bookies); hasBookies = true; } } if (readonly) { Set<BookieSocketAddress> bookies = result( regClient.getReadOnlyBookies() ).getValue(); if (!bookies.isEmpty()) { System.out.println("Readonly Bookies :"); printBookies(bookies); hasBookies = true; } } if (!hasBookies) { System.err.println("No bookie exists!"); } }
Source:
<code>public void handleCancelOk(String consumerTag) { if (this.logger.isDebugEnabled()) { this.logger.debug("CancelOk " + this); } synchronized (DirectMessageListenerContainer.this.consumersMonitor) { DirectMessageListenerContainer.this.cancellationLock.release(this); <START> DirectMessageListenerContainer.this.consumers.remove(this); <END> } RabbitUtils.closeChannel(getChannel()); }</code><technical_language>remove Consumer consumersByQueue well, do in handleCancel()</technical_language>

Target:
public void handleCancelOk(String consumerTag) { if (this.logger.isDebugEnabled()) { this.logger.debug("CancelOk " + this); } removeConsumer(); }
Source:
<code>public void analyze(UUID userAnonymizedId, UUID deviceAnonymizedId, AppActivitiesDto appActivities) { UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId); DeviceAnonymizedDto deviceAnonymized = deviceService.getDeviceAnonymized(userAnonymized, deviceAnonymizedId); Duration deviceTimeOffset = determineDeviceTimeOffset(appActivities); ActivityPayload[] activityPayloads = appActivities.getActivitiesSorted().stream() .map(appActivity -> createActivityPayload(deviceTimeOffset, appActivity, userAnonymized, deviceAnonymized)) <START> .toArray(ActivityPayload[]::new); <END> analyze(activityPayloads); }</code><technical_language>mapping this array? Lists easier work with</technical_language>

Target:
public void analyze(UUID userAnonymizedId, UUID deviceAnonymizedId, AppActivitiesDto appActivities) { UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId); DeviceAnonymizedDto deviceAnonymized = deviceService.getDeviceAnonymized(userAnonymized, deviceAnonymizedId); Duration deviceTimeOffset = determineDeviceTimeOffset(appActivities); List<ActivityPayload> activityPayloads = appActivities.getActivitiesSorted().stream() .map(appActivity -> createActivityPayload(deviceTimeOffset, appActivity, userAnonymized, deviceAnonymized)) .collect(Collectors.toList()); analyze(activityPayloads, userAnonymized); }
Source:
<code>private static void updatePscanTagMailtoPattern(XMLConfiguration config) { String autoTagScannersKey = "pscans.autoTagScanners.scanner"; List<HierarchicalConfiguration> tagScanners = config.configurationsAt(autoTagScannersKey); String badPattern = "<.*href\\s*['\"]?mailto:"; String goodPattern = "<.*href\\s*=['\"]?mailto:"; for (int i = 0, size = tagScanners.size(); i < size; ++i) { String elementBaseKey = autoTagScannersKey + "(" + i + ")."; String currentKeyResBodyRegex = elementBaseKey + "resBodyRegex"; if (config.getProperty(currentKeyResBodyRegex).equals(badPattern)) { config.setProperty(currentKeyResBodyRegex, goodPattern); break; } } <START> try { <END> config.save(); } catch (ConfigurationException ce) { LOG.warn("Unable to save config after upgrading MailTo autoTagScanner", ce); } }</code><technical_language>shouldn't, config is saved calling upgradeFrom_ methods (when setting latest version). I tested this statement tag updated in file</technical_language>

Target:
private static void updatePscanTagMailtoPattern(XMLConfiguration config) { String autoTagScannersKey = "pscans.autoTagScanners.scanner"; List<HierarchicalConfiguration> tagScanners = config.configurationsAt(autoTagScannersKey); String badPattern = "<.*href\\s*['\"]?mailto:"; String goodPattern = "<.*href\\s*=\\s*['\"]?mailto:"; for (int i = 0, size = tagScanners.size(); i < size; ++i) { String currentKeyResBodyRegex = autoTagScannersKey + "(" + i + ").resBodyRegex"; if (config.getProperty(currentKeyResBodyRegex).equals(badPattern)) { config.setProperty(currentKeyResBodyRegex, goodPattern); break; } } }
Source:
<code>protected void onPostExecute(final String response) { if (response != null) { try { final JsonObject githubStableObject = JsonParser.object().from(response) .getObject("flavors").getObject("github").getObject("stable"); <START> System.err.println("appelflapsausautomaat"); System.err.println(JsonWriter.string(githubStableObject)); <END> final String versionName = githubStableObject.getString("version"); final int versionCode = githubStableObject.getInt("version_code"); final String apkLocationUrl = githubStableObject.getString("apk"); compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode); } catch (JsonParserException e) { if (DEBUG) { Log.w(TAG, Log.getStackTraceString(e)); } } } }</code><technical_language>lines</technical_language>

Target:
protected void onPostExecute(final String response) { if (response != null) { try { final JsonObject githubStableObject = JsonParser.object().from(response) .getObject("flavors").getObject("github").getObject("stable"); final String versionName = githubStableObject.getString("version"); final int versionCode = githubStableObject.getInt("version_code"); final String apkLocationUrl = githubStableObject.getString("apk"); compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode); } catch (JsonParserException e) { if (DEBUG) { Log.w(TAG, Log.getStackTraceString(e)); } } } }
Source:
<code><START> protected Traverser<GraphQLType> initTraverser() { <END> return Traverser.depthFirst(getChildren); }</code><technical_language>protected? I private. design for inheritance: if is customizable done in another way</technical_language>

Target:
private Traverser<GraphQLType> initTraverser() { return Traverser.depthFirst(getChildren); }
Source:
<code>public static String convertEOL(String input, EOLType type) { input = input.replace("\r\n","\n"); input = input.replace("\r","\n"); <START> if (EOLType.Unix == type) <END> { return input; } input = input.replace("\n","\r\n"); return input; }</code><technical_language>switches explicit "default" behavior. Usage of external library (like @daniel-beck proposed) useful</technical_language>

Target:
public static String convertEOL(String input, EOLType type) { if (null == input || 0 == input.length()) { return input; } input = input.replace("\r\n","\n"); input = input.replace("\r","\n"); switch (type) { case CR: case Mac: input = input.replace("\n", "\r"); break; case CRLF: case Windows: input = input.replace("\n", "\r\n"); break; default: case LF: case Unix: return input; case LFCR: input = input.replace("\n", "\n\r"); break; } return input; }
Source:
<code>protected void addColumns() { for (ActionParameter actionParameter: actionsTable.getActionParameters()) { <START> String columnName = actionParameter.getName(); <END> TableViewerColumn column = createColumn( columnName, 2, new DataboundCellLabelProvider<ScriptGeneratorAction>(observeProperty(columnName)) { @Override protected String stringFromRow(ScriptGeneratorAction row) { return row.getActionParameterValue(columnName); } }); column.setEditingSupport(new StringEditingSupport<ScriptGeneratorAction>(viewer(), ScriptGeneratorAction.class) { @Override protected String valueFromRow(ScriptGeneratorAction row) { return row.getActionParameterValue(columnName); } @Override protected void setValueForRow(ScriptGeneratorAction row, String value) { row.setActionParameterValue(columnName, value); } }); } }</code><technical_language>actionParameter</technical_language>

Target:
protected void addColumns() { for (ActionParameter actionParameter: actionsTable.getActionParameters()) { String columnName = actionParameter.getName(); TableViewerColumn column = createColumn( columnName, 2, new DataboundCellLabelProvider<ScriptGeneratorAction>(observeProperty(columnName)) { @Override protected String stringFromRow(ScriptGeneratorAction row) { return row.getActionParameterValue(actionParameter); } }); column.setEditingSupport(new StringEditingSupport<ScriptGeneratorAction>(viewer(), ScriptGeneratorAction.class) { @Override protected String valueFromRow(ScriptGeneratorAction row) { return row.getActionParameterValue(actionParameter); } @Override protected void setValueForRow(ScriptGeneratorAction row, String value) { row.setActionParameterValue(actionParameter, value); } }); } }
Source:
<code>private Map<String, String> parsePanickedAttributes() { List<String> buffer = ContainerUtil.newArrayList(); Matcher matcher; <START> int i = myStdOut.size() - 1; <END> while (StringUtil.isEmptyOrSpaces(myStdOut.get(i))) { --i; } while (!StringUtil.isEmptyOrSpaces(myStdOut.get(i))) { buffer.add(myStdOut.get(i)); --i; } Collections.reverse(buffer); String details = StringUtil.join(buffer, ""); --i; String errorMessage = ""; if ((matcher = PANIC_VALUE.matcher(myStdOut.get(i))).matches()) { String stdoutLeftover = matcher.group(1); if (!StringUtil.isEmptyOrSpaces(stdoutLeftover)) { myStdOut.set(i, stdoutLeftover); ++i; } errorMessage = matcher.group(2); } Map<String, String> attributes = ContainerUtil.newHashMap(); attributes.put("message", errorMessage); attributes.put("details", details); myStdOut = myStdOut.subList(0, i); return attributes; }</code><technical_language>complicated buggy code (IOOBE everywhere). explain want archive</technical_language>

Target:
private Map<String, String> parsePanickedAttributes() { assert myStdOut != null: "expected to be called from a context where myStdOut is not null"; int i = myStdOut.size() - 1; Map<String, String> attributes = ContainerUtil.newHashMap(); try { List<String> buffer = ContainerUtil.newArrayList(); Matcher matcher; while (StringUtil.isEmptyOrSpaces(myStdOut.get(i))) { --i; }; while (!StringUtil.isEmptyOrSpaces(myStdOut.get(i))) { buffer.add(myStdOut.get(i--)); } Collections.reverse(buffer); attributes.put("details", StringUtil.join(buffer, "")); --i; String errorMessage = ""; if ((matcher = PANIC_VALUE.matcher(myStdOut.get(i))).matches()) { String stdoutLeftover = matcher.group(1); if (!StringUtil.isEmptyOrSpaces(stdoutLeftover)) { myStdOut.set(i, stdoutLeftover); ++i; } errorMessage = matcher.group(2); } attributes.put("message", errorMessage); } catch (IndexOutOfBoundsException e) { return Collections.emptyMap(); } myStdOut = myStdOut.subList(0, i); return attributes; }
Source:
<code>protected void initialize() { DefaultListModel<CharsetEntry> defaultListModel = new DefaultListModel<>(); for (CharsetEntry commonCharsetEntry : commonCharsetEntries) { try { if (Charset.isSupported(commonCharsetEntry.getCharsetName())) { defaultListModel.addElement(commonCharsetEntry); } } catch (IllegalCharsetNameException e) { } } SortedMap<String,Charset> charsetSortedMap = Charset.availableCharsets(); for (Map.Entry<String, Charset> charsetMapEntry : charsetSortedMap.entrySet()) { CharsetEntry charsetEntry = new CharsetEntry(charsetMapEntry.getValue().displayName(), charsetMapEntry.getKey()); if (!defaultListModel.contains(charsetEntry)) { defaultListModel.addElement(charsetEntry); } } listCharset.setModel(defaultListModel); if (defaultListModel.size() > 0) { listCharset.setSelectedIndex(0); <START> listCharset.addListSelectionListener(e -> updatePreview()); <END> } else { JOptionPane.showMessageDialog(this, "It appears that your installed Java Runtime Environment does not support any charset encodings!", "Error", JOptionPane.ERROR_MESSAGE); } }</code><technical_language>a lambda arg is __ (two underscores) argument's name express ignored. This be: java listCharset.addListSelectionListener(__ -> updatePreview());</technical_language>

Target:
protected void initialize() { DefaultListModel<CharsetEntry> defaultListModel = new DefaultListModel<>(); for (CharsetEntry commonCharsetEntry : commonCharsetEntries) { try { if (Charset.isSupported(commonCharsetEntry.getCharsetName())) { defaultListModel.addElement(commonCharsetEntry); } } catch (IllegalCharsetNameException e) { } } SortedMap<String,Charset> charsetSortedMap = Charset.availableCharsets(); for (Map.Entry<String, Charset> charsetMapEntry : charsetSortedMap.entrySet()) { CharsetEntry charsetEntry = new CharsetEntry(charsetMapEntry.getValue().displayName(), charsetMapEntry.getKey()); if (!defaultListModel.contains(charsetEntry)) { defaultListModel.addElement(charsetEntry); } } listCharset.setModel(defaultListModel); if (defaultListModel.size() > 0) { listCharset.setSelectedIndex(0); listCharset.addListSelectionListener(__ -> updatePreview()); } else { JOptionPane.showMessageDialog(this, "It appears that your installed Java Runtime Environment does not support any charset encodings!", "Error", JOptionPane.ERROR_MESSAGE); } }
Source:
<code>public void stop() { try { <START> cloudTable.deleteIfExists(); <END> } catch (StorageException e) { LOG.error("Azure Storage failed when creating a table", e); } taskNames.clear(); }</code><technical_language>If delete table checkpointManager.stop is called, this persisted checkpoint data is lost? want checkpoint data persist job is stopped, a restart want load previous checkpoint</technical_language>

Target:
public void stop() { }
Source:
<code>public void removeFromTabListDelayed(@Nullable final ServerPlayerEntity player, final SPlayerListItemPacket removePacket) { final int delay = SpongeImpl.getGlobalConfigAdapter().getConfig().getEntity().getHumanPlayerListRemoveDelay(); final Runnable removeTask = () -> this.pushPackets(player, removePacket); if (delay == 0) { removeTask.run(); } else { <START> SpongeImpl.getGame().getAsyncScheduler().submit(Task.builder() <END> .execute(removeTask) .delayTicks(delay) .plugin(SpongeImpl.getPlugin()) .build()); } }</code><technical_language>This executed exact number of ticks, async</technical_language>

Target:
public void removeFromTabListDelayed(@Nullable final ServerPlayerEntity player, final SPlayerListItemPacket removePacket) { final int delay = SpongeImpl.getGlobalConfigAdapter().getConfig().getEntity().getHumanPlayerListRemoveDelay(); final Runnable removeTask = () -> this.pushPackets(player, removePacket); if (delay == 0) { removeTask.run(); } else { Sponge.getServer().getScheduler().submit(Task.builder() .execute(removeTask) .delayTicks(delay) .plugin(SpongeImpl.getPlugin()) .build()); } }
Source:
<code>public MetricsMode register(MetricsMode mode) { metricsModes.add(mode); <START> return mode; <END> }</code><technical_language>this method return void instead? I feel a bit funny return provided input</technical_language>

Target:
public boolean register(MetricsMode mode) { Preconditions.checkNotNull(mode, "Illegal argument passed, mode is null."); if (!modes.contains(mode)) { return modes.add(mode); } else { return false; } }
Source:
<code>final protected void executeValidatedCommands(CommandBase<?> command) { <START> if (command.getReturnValue().getCanDoAction()) { <END> String correlationId = command.getParameters().getCorrelationId(); command.setCorrelationId(correlationId); if (executionContext == null || executionContext.isMonitored()) { ExecutionHandler.prepareCommandForMonitoring(command, command.getActionType(), command.isInternalExecution(), correlationId); } ThreadLocalParamsContainer.setCorrelationId(correlationId); command.ExecuteAction(); } }</code><technical_language>set correlationId constructor commandBase</technical_language>

Target:
final protected void executeValidatedCommands(CommandBase<?> command) { if (command.getReturnValue().getCanDoAction()) { if (executionContext == null || executionContext.isMonitored()) { ExecutionHandler.prepareCommandForMonitoring(command, command.getActionType(), command.isInternalExecution()); } ThreadLocalParamsContainer.setCorrelationId(command.getCorrelationId()); command.ExecuteAction(); } }
Source:
<code>protected boolean validate() { if (getParameters() == null || getParameters().getAgent() == null || getParameters().getAgent().getIp() == null || getParameters().getAgent().getHostId() == null || getParameters().getAgent().getPassword() == null || getParameters().getAgent().getType() == null || getParameters().getAgent().getUser() == null) { return failValidation(EngineMessage.VDS_ADD_FENCE_AGENT_MANDATORY_PARAMETERS_MISSING); } Guid vdsId = getParameters().getAgent().getHostId(); VDS vds = vdsDao.get(vdsId); Guid vdsClusterId = vds.getClusterId(); Cluster cluster = clusterDao.get(vdsClusterId); String clusterCompatibilityVersion = cluster.getCompatibilityVersion().toString(); if <START> (!Regex.isMatch(FenceConfigHelper.getFenceConfigurationValue(ConfigValues.VdsFenceType.name(), <END> clusterCompatibilityVersion), String.format("(,|^)%1$s(,|$)", getParameters().getAgent().getType()))) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_AGENT_NOT_SUPPORTED); } return super.validate(); }</code><technical_language>suggest avoid this class. is a leftover of C# times. java.util.regex.Pattern class, if possible</technical_language>

Target:
protected boolean validate() { if (getParameters() == null || getParameters().getAgent() == null || getParameters().getAgent().getIp() == null || getParameters().getAgent().getHostId() == null || getParameters().getAgent().getPassword() == null || getParameters().getAgent().getType() == null || getParameters().getAgent().getUser() == null) { return failValidation(EngineMessage.VDS_ADD_FENCE_AGENT_MANDATORY_PARAMETERS_MISSING); } Guid vdsId = getParameters().getAgent().getHostId(); VDS vds = vdsDao.get(vdsId); Guid vdsClusterId = vds.getClusterId(); Cluster cluster = clusterDao.get(vdsClusterId); String clusterCompatibilityVersion = cluster.getCompatibilityVersion().toString(); if (!FenceConfigHelper.getValidFenceAgentTypes(clusterCompatibilityVersion) .contains(getParameters().getAgent().getType())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_AGENT_NOT_SUPPORTED); } return super.validate(); }