auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final Option<SPTarget> targetOpt = getSelectedPos(); if (targetOpt.isDefined()) { final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) PrimaryTargetToggle.instance.toggle(_dataObject, targetOpt.getValue()); } else { getSelectedGroup().foreach(igg -> { final TargetEnvironment env = _dataObject.getTargetEnvironment(); final GuideGroup primary = env.getOrCreatePrimaryGuideGroup(); final GuideGrp grp = igg.group().grp(); final GuideEnvironment ge = env.getGuideEnvironment(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); } }

Target:
void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final Option<SPTarget> targetOpt = getSelectedPos(); if (targetOpt.isDefined()) { final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) PrimaryTargetToggle.instance.toggle(_dataObject, targetOpt.getValue()); } else { getSelectedGroup().foreach(igg -> { final TargetEnvironment env = _dataObject.getTargetEnvironment(); final GuideGroup primary = env.getOrCreatePrimaryGuideGroup(); ImOption.apply(env.getGuideEnvironment()).foreach(ge -> { final GuideGrp grp = igg.group().grp(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); }); } }
Source:
public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); secretAsyncClient.setSecret(new Secret("StorageAccountPassword", "f4G34fMh8v-fdsgjsk2323=-asdsdfsdf") .setExpires(OffsetDateTime.now().plusYears(1))) .subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s \n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); String backupFilePath = "YOUR_BACKUP_FILE_PATH"; secretAsyncClient.backupSecret("StorageAccountPassword").subscribe(backupResponse -> { byte[] backupBytes = backupResponse; writeBackupToFile(backupBytes, backupFilePath); }); Thread.sleep(7000); secretAsyncClient.deleteSecret("StorageAccountPassword").subscribe(deletedSecretResponse -> System.out.printf("Deleted Secret's Recovery Id %s \n", deletedSecretResponse.getRecoveryId())); Thread.sleep(30000); secretAsyncClient.purgeDeletedSecretWithResponse("StorageAccountPassword").subscribe(purgeResponse -> System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); Thread.sleep(15000); byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); secretAsyncClient.restoreSecret(backupFromFile).subscribe(secretResponse -> System.out.printf("Restored Secret with name %s \n", secretResponse.getName())); Thread.sleep(15000); }

Target:
public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); secretAsyncClient.setSecret(new Secret("StorageAccountPassword", "f4G34fMh8v-fdsgjsk2323=-asdsdfsdf") .setExpires(OffsetDateTime.now().plusYears(1))) .subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s %n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); String backupFilePath = "YOUR_BACKUP_FILE_PATH"; secretAsyncClient.backupSecret("StorageAccountPassword").subscribe(backupResponse -> { byte[] backupBytes = backupResponse; writeBackupToFile(backupBytes, backupFilePath); }); Thread.sleep(7000); secretAsyncClient.deleteSecret("StorageAccountPassword").subscribe(deletedSecretResponse -> System.out.printf("Deleted Secret's Recovery Id %s %n", deletedSecretResponse.getRecoveryId())); Thread.sleep(30000); secretAsyncClient.purgeDeletedSecretWithResponse("StorageAccountPassword").subscribe(purgeResponse -> System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); Thread.sleep(15000); byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); secretAsyncClient.restoreSecret(backupFromFile).subscribe(secretResponse -> System.out.printf("Restored Secret with name %s %n", secretResponse.getName())); Thread.sleep(15000); }
Source:
private void handleForcedToPayOnlyForCurrentPayment(Game game, ManaPool pool, ManaCosts referenceCosts) { if (pool.isForcedToPay()) { if (referenceCosts != null && this.getPayment().equals(referenceCosts.getPayment())) { UUID playerId = pool.getPlayerId(); Player player = game.getPlayer(playerId); if (player != null) { game.undo(playerId); this.clearPaid(); game.bookmarkState(); } } } }

Target:
private void handleForcedToPayOnlyForCurrentPayment(Game game, ManaPool pool, ManaCosts referenceCosts) { if (pool.isForcedToPay()) { if (referenceCosts != null && this.getText().equals(referenceCosts.getText())) { UUID playerId = pool.getPlayerId(); Player player = game.getPlayer(playerId); if (player != null) { game.undo(playerId); this.clearPaid(); this.setX(referenceCosts.getX()); player.getManaPool().restoreMana(pool.getPoolBookmark()); game.bookmarkState(); } } } }
Source:
protected void onMethodInvocationFound(MethodInvocationTree mit) { ExpressionTree argument = mit.arguments().get(0); if (mit.symbolType().is(PATTERN)) { if (argument.is(Tree.Kind.NULL_LITERAL) || (checkArgs(argument) && invokedOnlyOnce(mit))) { return; } } else { if (!argument.is(Tree.Kind.STRING_LITERAL) || ("split".equals(((MemberSelectExpressionTree) mit.methodSelect()).identifier().name()) && specialCaseNotReported(argument))) { return; } } reportIssue(mit, "Refactor this code to use a \"static final\" Pattern."); }

Target:
protected void onMethodInvocationFound(MethodInvocationTree mit) { ExpressionTree firstArgument = ExpressionUtils.skipParentheses(mit.arguments().get(0)); if (isSplitMethod(mit) && firstArgument.is(Tree.Kind.STRING_LITERAL)) { String argValue = LiteralUtils.trimQuotes(((LiteralTree) firstArgument).value()); if ((exceptionSplitMethod(argValue) && !SPLIT_EXCLUSION.matcher(argValue).matches()) || metaCharactersInSplit(argValue)) { return; } } if (!storedInStaticFinal(mit) && (firstArgument.is(Tree.Kind.STRING_LITERAL) || isConstant(firstArgument))) { reportIssue(ExpressionUtils.methodName(mit), mit.arguments(), "Refactor this code to use a \"static final\" Pattern."); } }
Source:
public void pageFindByCandidateEntityShouldFindSingleApplicationForCandidateWithSingleApplication() { CandidateEntity candidateEntityA = this.candidateRepository.findOne(CANDIDATE_A_ID); ChannelEntity expectedChannelEntity = ChannelEntity.builder() .id(1L) .name("direkt") .build(); PositionEntity expectedPositionEntity = PositionEntity.builder() .id(1L) .name("Fejlesztő") .build(); Date nearNow = currentDateMinus(5); Page<ApplicationEntity> pageResult = this.repository.findByCandidateEntity(candidateEntityA, DEFAULT_PAGE_REQUEST); List<ApplicationEntity> result = pageResult.getContent(); assertThat(pageResult.getTotalPages(), is(1)); assertThat(pageResult.getTotalElements(), is(1L)); assertThat(result, notNullValue()); assertThat(result.size(), is(1)); assertApplicationEntity(result.get(0), candidateEntityA, expectedChannelEntity, expectedPositionEntity, nearNow); }

Target:
public void pageFindByCandidateEntityShouldFindSingleApplicationForCandidateWithSingleApplication() { CandidateEntity candidateEntityA = this.candidateRepository.findOne(CANDIDATE_A_ID); ChannelEntity expectedChannelEntity = ChannelEntity.builder() .id(1L) .name(CHANNEL_NAME_DIRECT) .deleted(false) .build(); PositionEntity expectedPositionEntity = PositionEntity.builder() .id(1L) .name(POSITION_NAME_DEVELOPER) .deleted(false) .build(); Date nearNow = currentDateMinus(5); final Page<ApplicationEntity> pageResult = this.repository.findByCandidateEntity(candidateEntityA, DEFAULT_PAGE_REQUEST); final List<ApplicationEntity> result = pageResult.getContent(); assertThat(pageResult.getTotalPages(), is(1)); assertThat(pageResult.getTotalElements(), is(1L)); assertThat(result, notNullValue()); assertThat(result.size(), is(1)); assertApplicationEntity(result.get(0), candidateEntityA, expectedChannelEntity, expectedPositionEntity, nearNow); }
Source:
public void testDrawTextAlignment() throws Exception { git.commit().setMessage("initial commit").call(); git.branchCreate().setName("topic").call(); git.checkout().setName("topic").call(); git.commit().setMessage("commit 1 on topic").call(); git.commit().setMessage("commit 2 on topic").call(); git.checkout().setName("master").call(); git.commit().setMessage("commit on master").call(); MergeResult mergeCall = merge(db.resolve("topic")); ObjectId start = mergeCall.getNewHead(); PlotCommitList<PlotLane> commitList = createCommitList(start); for (int i = 0; i < commitList.size(); i++) { plotRenderer.paintCommit(commitList.get(i), 30); } List<Integer> indentations = plotRenderer.indentations; assertEquals(indentations.get(2), indentations.get(3)); }

Target:
public void testDrawTextAlignment() throws Exception { git.commit().setMessage("initial commit").call(); git.branchCreate().setName("topic").call(); git.checkout().setName("topic").call(); git.commit().setMessage("commit 1 on topic").call(); git.commit().setMessage("commit 2 on topic").call(); git.checkout().setName("master").call(); git.commit().setMessage("commit on master").call(); MergeResult mergeCall = merge(db.resolve("topic")); ObjectId start = mergeCall.getNewHead(); PlotCommitList<PlotLane> commitList = createCommitList(start); for (int i = 0; i < commitList.size(); i++) plotRenderer.paintCommit(commitList.get(i), 30); List<Integer> indentations = plotRenderer.indentations; assertEquals(indentations.get(2), indentations.get(3)); }
Source:
public void initProperties(IMemento memento) { IMemento presentationMemento = null; for (IMemento memento2 : memento.getChildren(PRESENTATION_CONTEXT_PROPERTIES)) { if (getId().equals(memento2.getID())) { presentationMemento = memento2; break; } } if (presentationMemento != null) { for (IMemento stringPropertie : presentationMemento.getChildren(STRING)) { fProperties.put(stringPropertie.getID(), stringPropertie.getString(STRING)); } for (IMemento integerMemento : presentationMemento.getChildren(INTEGER)) { fProperties.put(integerMemento.getID(), integerMemento.getInteger(INTEGER)); } for (IMemento booleanMemento : presentationMemento.getChildren(BOOLEAN)) { fProperties.put(booleanMemento.getID(), booleanMemento.getBoolean(BOOLEAN)); } for (IMemento persistableMemento : presentationMemento.getChildren(PERSISTABLE)) { String factoryID = persistableMemento.getString(PERSISTABLE); if (factoryID != null) { IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID); if (factory != null) { Object element = factory.createElement(persistableMemento); if (element != null) { fProperties.put(persistableMemento.getID(), element); } } } } } }

Target:
public void initProperties(IMemento memento) { IMemento presentationMemento = null; for (IMemento childMemento : memento.getChildren(PRESENTATION_CONTEXT_PROPERTIES)) { if (getId().equals(childMemento.getID())) { presentationMemento = childMemento; break; } } if (presentationMemento != null) { for (IMemento stringProperty : presentationMemento.getChildren(STRING)) { fProperties.put(stringProperty.getID(), stringProperty.getString(STRING)); } for (IMemento integerMemento : presentationMemento.getChildren(INTEGER)) { fProperties.put(integerMemento.getID(), integerMemento.getInteger(INTEGER)); } for (IMemento booleanMemento : presentationMemento.getChildren(BOOLEAN)) { fProperties.put(booleanMemento.getID(), booleanMemento.getBoolean(BOOLEAN)); } for (IMemento persistableMemento : presentationMemento.getChildren(PERSISTABLE)) { String factoryID = persistableMemento.getString(PERSISTABLE); if (factoryID != null) { IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID); if (factory != null) { Object element = factory.createElement(persistableMemento); if (element != null) { fProperties.put(persistableMemento.getID(), element); } } } } } }
Source:
public void testListAllLibraryTypes() throws Exception { List<LibraryType> libraryTypes = dao.listAllLibraryTypes(); assertTrue(libraryTypes.size() > 0); }

Target:
public void testListAllLibraryTypes() throws Exception { List<LibraryType> libraryTypes = dao.listAllLibraryTypes(); assertEquals(10, libraryTypes.size()); }
Source:
@Test public void nullSqlWontNPE() throws SQLException { ConcurrentLinkedDeque<zipkin.Span> spans = new ConcurrentLinkedDeque<>(); Tracing tracing = ITTracingP6Factory.tracingBuilder(Sampler.ALWAYS_SAMPLE, spans).build(); when(statementInformation.getSql()).thenReturn(null); when(statementInformation.getConnectionInformation()).thenReturn(ci); when(ci.getConnection()).thenReturn(connection); when(connection.getMetaData()).thenReturn(metaData); when(metaData.getURL()).thenReturn(url); TracingJdbcEventListener listener = new TracingJdbcEventListener("", false); listener.onBeforeAnyExecute(statementInformation); listener.onAfterAnyExecute(statementInformation,1,null); assertThat(spans.getFirst().name, is(equalTo(TracingJdbcEventListener.QUERY_PLACEHOLDER.trim()))); }

Target:
@Test public void nullSqlWontNPE() throws SQLException { ConcurrentLinkedDeque<zipkin.Span> spans = new ConcurrentLinkedDeque<>(); Tracing tracing = ITTracingP6Factory.tracingBuilder(Sampler.ALWAYS_SAMPLE, spans).build(); when(statementInformation.getSql()).thenReturn(null); when(statementInformation.getConnectionInformation()).thenReturn(ci); when(ci.getConnection()).thenReturn(connection); when(connection.getMetaData()).thenReturn(metaData); when(metaData.getURL()).thenReturn(url); TracingJdbcEventListener listener = new TracingJdbcEventListener("", false); listener.onBeforeAnyExecute(statementInformation); listener.onAfterAnyExecute(statementInformation,1,null); assertThat(spans) .extracting(s -> s.name) .containsExactly("query"); }
Source:
public static void checkMinLength(String propertyName, String actualValue, int minLength) throws MinSizeExceededException{ if(actualValue.length() < minLength) throw new MinSizeExceededException("Length of '" + propertyName + "' is too short! MinLength=" + minLength + ", ActualLength=" + actualValue.length()); }

Target:
public static void checkMinLength(String propertyName, String actualValue, int minLength) throws MinSizeExceededException { if (actualValue == null) { throw new MinSizeExceededException("The property '" + propertyName + "' does not have a minimal length equal to '" + minLength + "' because it is null."); } if (actualValue.length() < minLength) { throw new MinSizeExceededException("Length of '" + propertyName + "' is too short! MinLength=" + minLength + ", ActualLength=" + actualValue.length()); } }
Source:
private JavaCharacter parseJavaEscapeSequence(JavaCharacter backslash) { unicodeProcessedCharacters.moveNext(); JavaCharacter javaCharacter = unicodeProcessedCharacters.getCurrent(); if (javaCharacter == null) { return null; } char ch = javaCharacter.getCharacter(); switch (ch) { case 'n': ch = '\n'; unicodeProcessedCharacters.moveNext(); break; case 'r': ch = '\r'; unicodeProcessedCharacters.moveNext(); break; case 'f': ch = '\f'; unicodeProcessedCharacters.moveNext(); break; case 'b': ch = '\b'; unicodeProcessedCharacters.moveNext(); break; case 't': ch = '\t'; unicodeProcessedCharacters.moveNext(); break; default: if (isOctalDigit(ch)) { StringBuilder codeUnit = new StringBuilder(3); for (int i = 0; i < 3 && javaCharacter != null && isOctalDigit(javaCharacter.getCharacter()); i++) { codeUnit.append(javaCharacter.getCharacter()); unicodeProcessedCharacters.moveNext(); javaCharacter = unicodeProcessedCharacters.getCurrent(); } ch = (char) Integer.parseInt(codeUnit.toString(), 8); } else { unicodeProcessedCharacters.moveNext(); } break; } return new JavaCharacter(source, backslash.getRange().extendTo(getCurrentStartIndex()), ch); }

Target:
private JavaCharacter parseJavaEscapeSequence(JavaCharacter backslash) { unicodeProcessedCharacters.moveNext(); JavaCharacter javaCharacter = unicodeProcessedCharacters.getCurrent(); if (javaCharacter == null) { return backslash; } char ch = javaCharacter.getCharacter(); switch (ch) { case 'n': ch = '\n'; break; case 'r': ch = '\r'; break; case 'f': ch = '\f'; break; case 'b': ch = '\b'; break; case 't': ch = '\t'; break; default: if (isOctalDigit(ch)) { StringBuilder codeUnit = new StringBuilder(3); for (int i = 0; i < 3 && javaCharacter != null && isOctalDigit(javaCharacter.getCharacter()); i++) { codeUnit.append(javaCharacter.getCharacter()); unicodeProcessedCharacters.moveNext(); javaCharacter = unicodeProcessedCharacters.getCurrent(); } ch = (char) Integer.parseInt(codeUnit.toString(), 8); return new JavaCharacter(source, backslash.getRange().extendTo(getCurrentStartIndex()), ch); } break; } unicodeProcessedCharacters.moveNext(); return new JavaCharacter(source, backslash.getRange().extendTo(getCurrentStartIndex()), ch); }
Source:
public Set<String> availableRoleIds() { String[] configStrings = ServerConfigurationService.getStrings("access.enabledRoles"); LinkedHashSet<String> availableIds = new LinkedHashSet<String>(); availableIds.addAll(Arrays.asList(configStrings)); if(!this.isPubviewPossible) { availableIds.remove(PUBVIEW_ROLE); } return availableIds; }

Target:
public Set<String> availableRoleIds() { String[] configStrings = ServerConfigurationService.getStrings("access.enabledRoles"); LinkedHashSet<String> availableIds = new LinkedHashSet<String>(); if(configStrings != null) { availableIds.addAll(Arrays.asList(configStrings)); } if(!this.isPubviewPossible) { availableIds.remove(PUBVIEW_ROLE); } return availableIds; }
Source:
protected Comparator<T> getDefaultItemComparator() { if (defaultItemComparator == null) { final Comparator<T> nameComparator = new Comparator<T>() { @Override public int compare(T a, T b) { String name1 = (a instanceof Nameable) ? ((Nameable) a).getName() : null; String name2 = (b instanceof Nameable) ? ((Nameable) b).getName() : null; return LexoNumericComparator.comp(name1, name2); } }; final Comparator<T> idComparator = new Comparator<T>() { private final Comparator<Comparable> nullComparator = new Comparator<Comparable>() { private final boolean nullFirst = false; @Override public int compare(Comparable a, Comparable b) { if (a == null) { return (b == null) ? 0 : (nullFirst ? -1 : 1); } else if (b == null) { return nullFirst ? 1: -1; } else { return a.compareTo(b); } } }; @Override public int compare(T a, T b) { Object id1 = (a instanceof IVdcQueryable) ? ((IVdcQueryable) a).getQueryableId() : null; Object id2 = (b instanceof IVdcQueryable) ? ((IVdcQueryable) b).getQueryableId() : null; Comparable idComp1 = (id1 instanceof Comparable) ? (Comparable) id1 : null; Comparable idComp2 = (id2 instanceof Comparable) ? (Comparable) id2 : null; return nullComparator.compare(idComp1, idComp2); } }; defaultItemComparator = new Comparator<T>() { @Override public int compare(T a, T b) { int res = nameComparator.compare(a, b); return (res != 0) ? res : idComparator.compare(a, b); } }; } return defaultItemComparator; }

Target:
protected Comparator<T> getDefaultItemComparator() { if (defaultItemComparator == null) { final Comparator<T> nameComparator = new Comparator<T>() { @Override public int compare(T a, T b) { String name1 = (a instanceof Nameable) ? ((Nameable) a).getName() : null; String name2 = (b instanceof Nameable) ? ((Nameable) b).getName() : null; return LexoNumericComparator.comp(name1, name2); } }; final Comparator<T> idComparator = new Comparator<T>() { private final Comparator<Comparable> nullComparator = new Comparator<Comparable>() { @Override public int compare(Comparable a, Comparable b) { if (a == null) { return (b == null) ? 0 : 1; } else if (b == null) { return -1; } else { return a.compareTo(b); } } }; @Override public int compare(T a, T b) { Object id1 = (a instanceof IVdcQueryable) ? ((IVdcQueryable) a).getQueryableId() : null; Object id2 = (b instanceof IVdcQueryable) ? ((IVdcQueryable) b).getQueryableId() : null; Comparable idComp1 = (id1 instanceof Comparable) ? (Comparable) id1 : null; Comparable idComp2 = (id2 instanceof Comparable) ? (Comparable) id2 : null; return nullComparator.compare(idComp1, idComp2); } }; defaultItemComparator = new Comparator<T>() { @Override public int compare(T a, T b) { int res = nameComparator.compare(a, b); return (res != 0) ? res : idComparator.compare(a, b); } }; } return defaultItemComparator; }
Source:
private void writeToDataOut(DataOutput out, Schema.Field field) throws IOException { Schema fieldSchema = getNonNullableSchema(field); Schema.Type fieldType = fieldSchema.getType(); Object fieldValue = record.get(field.getName()); if (fieldValue == null) { return; } switch (fieldType) { case NULL: break; case STRING: out.writeUTF((String) fieldValue); break; case BOOLEAN: out.writeBoolean((Boolean) fieldValue); break; case INT: out.writeInt((Integer) fieldValue); break; case LONG: out.writeLong((Long) fieldValue); break; case FLOAT: out.writeFloat((Float) fieldValue); break; case DOUBLE: out.writeDouble((Double) fieldValue); break; case BYTES: out.write((byte[]) fieldValue); break; default: throw new IOException(String.format("Unsupported datatype: %s with value: %s and name: %s.", fieldType, fieldValue, field.getName())); } }

Target:
private void writeToDataOut(DataOutput out, Schema.Field field) throws IOException { Schema fieldSchema = getNonNullableSchema(field); Schema.Type fieldType = fieldSchema.getType(); Object fieldValue = record.get(field.getName()); if (fieldValue == null) { return; } switch (fieldType) { case NULL: break; case STRING: out.writeUTF((String) fieldValue); break; case BOOLEAN: out.writeBoolean((Boolean) fieldValue); break; case INT: out.writeInt((Integer) fieldValue); break; case LONG: out.writeLong((Long) fieldValue); break; case FLOAT: out.writeFloat((Float) fieldValue); break; case DOUBLE: out.writeDouble((Double) fieldValue); break; case BYTES: out.write((byte[]) fieldValue); break; default: throw new IOException(String.format("Column %s with value %s has an unsupported datatype %s", field.getName(), fieldValue, fieldType)); } }
Source:
public synchronized Set<Long> requestIdsSnapshot() { return new HashSet<Long>(requestSent.keySet()); }

Target:
public Set<Long> requestIdsSnapshot() { synchronized (FastSyncManager.this) { return new HashSet<Long>(requestSent.keySet()); } }
Source:
public void applySecret(KubernetesEnvironment env, RuntimeIdentity runtimeIdentity, Secret secret) throws InfrastructureException { super.applySecret(env, runtimeIdentity, secret); final String secretMountPath = secret.getMetadata().getAnnotations().get(ANNOTATION_MOUNT_PATH); Set<String> keys = secret.getData().keySet(); if (keys.size() != 1) { throw new InfrastructureException( format( "Invalid git credential secret data. It should contain only 1 data item but it have %d", keys.size())); } Path gitSecretFilePath = Paths.get(secretMountPath, keys.iterator().next()); ConfigMap gitConfigMap = env.getConfigMaps() .get( runtimeIdentity.getWorkspaceId() + GitConfigProvisioner.GIT_CONFIG_MAP_NAME_SUFFIX); if (gitConfigMap != null) { Map<String, String> gitConfigMapData = gitConfigMap.getData(); String gitConfig = gitConfigMapData.get(GitConfigProvisioner.GIT_CONFIG); if (gitConfig != null) { if (gitConfig.contains("helper = store --file ") && gitConfig.contains("[credential]")) { throw new InfrastructureException( "Multiple git credentials secrets found. Please remove duplication."); } StringBuilder gitConfigBuilder = new StringBuilder(gitConfig); gitConfigBuilder .append('\n') .append("[credential]") .append('\n') .append('\t') .append("helper = store --file ") .append(gitSecretFilePath.toString()) .append('\n'); HashMap<String, String> newGitConfigMapData = new HashMap<>(gitConfigMapData); newGitConfigMapData.put(GitConfigProvisioner.GIT_CONFIG, gitConfigBuilder.toString()); LOG.info(gitConfigBuilder.toString()); gitConfigMap.setData(newGitConfigMapData); } } }

Target:
public void applySecret(KubernetesEnvironment env, RuntimeIdentity runtimeIdentity, Secret secret) throws InfrastructureException { super.applySecret(env, runtimeIdentity, secret); final String secretMountPath = secret.getMetadata().getAnnotations().get(ANNOTATION_MOUNT_PATH); Set<String> keys = secret.getData().keySet(); if (keys.size() != 1) { throw new InfrastructureException( format( "Invalid git credential secret data. It should contain only 1 data item but it have %d", keys.size())); } Path gitSecretFilePath = Paths.get(secretMountPath, keys.iterator().next()); ConfigMap gitConfigMap = env.getConfigMaps() .get( runtimeIdentity.getWorkspaceId() + GitConfigProvisioner.GIT_CONFIG_MAP_NAME_SUFFIX); if (gitConfigMap != null) { Map<String, String> gitConfigMapData = gitConfigMap.getData(); String gitConfig = gitConfigMapData.get(GitConfigProvisioner.GIT_CONFIG); if (gitConfig != null) { if (gitConfig.contains("helper = store --file") && gitConfig.contains("[credential]")) { throw new InfrastructureException( "Multiple git credentials secrets found. Please remove duplication."); } HashMap<String, String> newGitConfigMapData = new HashMap<>(gitConfigMapData); newGitConfigMapData.put( GitConfigProvisioner.GIT_CONFIG, String.format(GIT_CREDENTIALS_FILE_STORE_PATTERN, gitSecretFilePath.toString())); gitConfigMap.setData(newGitConfigMapData); } } }
Source:
public void validate() { throw new CacheConfigurationException("MODULE ERROR"); }

Target:
public void validate() { throw new RuntimeException("MODULE ERROR"); }
Source:
public static ChangeData createForTest(Change.Id id, int currentPatchSetId) { ChangeData cd = new ChangeData(null, null, null, null, null, null, null, null, null, null, null, null, null, id); cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId)); return cd; }

Target:
static ChangeData createForTest(Change.Id id, int currentPatchSetId) { ChangeData cd = new ChangeData(null, null, null, null, null, null, null, null, null, null, null, null, null, id); cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId)); return cd; }
Source:
public final String toString() { StringBuilder builder = new StringBuilder(); builder.append("Path to theme: "); builder.append(getPath()); builder.append(", User portal css: "); builder.append(getUserPortalStyleSheetName()); builder.append(", Web admin css: "); builder.append(getWebadminStyleSheetName()); return builder.toString(); }

Target:
public final String toString() { return "Path to theme: " + getPath() + ", User portal css: " + getUserPortalStyleSheetName() + ", Web admin css: " + getWebadminStyleSheetName(); }
Source:
protected Iterator<Event> historyBackward() { final ImmutableList<Event> events = ImmutableList.copyOf(historySinceLastSnapshot); return events.iterator(); }

Target:
protected Iterator<Event> historyBackward() { return recentHistory().iterator(); }
Source:
protected void setupCloudClient() { try { String projectId = getProperty(PROJECT_ID_PROPERTY); GoogleCredentials credentials = GoogleCredentials.fromStream(new ByteArrayInputStream( Files.readAllBytes(Paths.get(getProperty(GOOGLE_APPLICATION_CREDENTIALS))))) .createScoped(GOOGLE_PLATFORM_SCOPE, GOOGLE_STORAGE_SCOPE); credentials.refreshIfExpired(); storage = StorageOptions.newBuilder() .setCredentials(GoogleCredentials.create(credentials.refreshAccessToken())) .setProjectId(projectId) .build() .getService(); bucketName = getProperty(BUCKET_NAME_PROPERTY); bucketPrefix = getProperty(BUCKET_PREFIX_PROPERTY, EMPTY); bucket = getOrCreateBucket(bucketName); if (!isBlank(bucketPrefix) && !bucketPrefix.endsWith(DELIMITER)) { log.warn(String.format("%s %s Google bucket prefix should end with '/' : added automatically.", BUCKET_PREFIX_PROPERTY, bucketPrefix)); bucketPrefix += DELIMITER; } if (isNotBlank(namespace)) { bucketPrefix += namespace; if (!bucketPrefix.endsWith(DELIMITER)) { bucketPrefix += DELIMITER; } } } catch (IOException e) { throw new NuxeoException(e); } }

Target:
protected void setupCloudClient() { try { String projectId = getProperty(PROJECT_ID_PROPERTY); File googleCredentials = new File(getProperty(GOOGLE_APPLICATION_CREDENTIALS)); String credentialsPath = googleCredentials.isFile() ? googleCredentials.getAbsolutePath() : new File(Environment.getDefault().getConfig(), getProperty(GOOGLE_APPLICATION_CREDENTIALS, GCP_JSON_FILE)).getAbsolutePath(); GoogleCredentials credentials = GoogleCredentials.fromStream( new ByteArrayInputStream(Files.readAllBytes(Paths.get(credentialsPath)))) .createScoped(GOOGLE_PLATFORM_SCOPE, GOOGLE_STORAGE_SCOPE); credentials.refreshIfExpired(); storage = StorageOptions.newBuilder() .setCredentials(GoogleCredentials.create(credentials.refreshAccessToken())) .setProjectId(projectId) .build() .getService(); bucketName = getProperty(BUCKET_NAME_PROPERTY); bucketPrefix = getProperty(BUCKET_PREFIX_PROPERTY, EMPTY); bucket = getOrCreateBucket(bucketName); if (!isBlank(bucketPrefix) && !bucketPrefix.endsWith(DELIMITER)) { log.warn(String.format("%s %s Google bucket prefix should end with '/' : added automatically.", BUCKET_PREFIX_PROPERTY, bucketPrefix)); bucketPrefix += DELIMITER; } if (isNotBlank(namespace)) { bucketPrefix += namespace; if (!bucketPrefix.endsWith(DELIMITER)) { bucketPrefix += DELIMITER; } } } catch (IOException e) { throw new NuxeoException(e); } }
Source:
public void scanFile(AstTreeVisitorContext context) { super.scanFile(context); RandomAccessFile randomAccessFile = null; try { randomAccessFile = new RandomAccessFile(getContext().getFile(), "r"); if (!endsWithNewline(randomAccessFile)) { getContext().addFileIssue(this, "Add a new line at the end of this file."); } } catch (IOException e) { LOG.error("Unable to execute rule \"MissingNewlineAtEndOfFile\" for file because of error: {}", getContext().getFile().getName(), e); } finally { Closeables.closeQuietly(randomAccessFile); } }

Target:
public void scanFile(AstTreeVisitorContext context) { super.scanFile(context); try (RandomAccessFile randomAccessFile = new RandomAccessFile(getContext().getFile(), "r")) { if (!endsWithNewline(randomAccessFile)) { getContext().addFileIssue(this, "Add a new line at the end of this file."); } } catch (IOException e) { LOG.error("Unable to execute rule \"MissingNewlineAtEndOfFile\" for file because of error: {}", getContext().getFile().getName(), e); } }
Source:
public void testAllScriptsNull() throws InvalidScriptException { Script s = null; FlowScript fs = null; Mockito.when(it.getPreScript()).thenReturn(s); Mockito.when(it.getPostScript()).thenReturn(s); Mockito.when(fe.getEnvScript()).thenReturn(s); Mockito.when(sec.getScript()).thenReturn(s); Mockito.when(it.getFlowScript()).thenReturn(fs); Boolean result = new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd); assertEquals(false, result); }

Target:
public void testAllScriptsNull() throws InvalidScriptException { Script s = null; FlowScript fs = null; Mockito.when(it.getPreScript()).thenReturn(s); Mockito.when(it.getPostScript()).thenReturn(s); Mockito.when(fe.getEnvScript()).thenReturn(s); Mockito.when(sec.getScript()).thenReturn(s); Mockito.when(it.getFlowScript()).thenReturn(fs); assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd)); }
Source:
public void end() { try { angle = motionController.getInputSafely(); } catch (InvalidSensorException e) { angle = 0; updateStatus(CHECK_NAME, SystemStatus.FAIL, e); } if (Math.abs(motionController.getSetpoint() - angle) > ERROR_THRESHOLD) { updateStatus(CHECK_NAME, SystemStatus.FAIL, new Exception("ANGLE TURNED NOT WITHIN ERROR THRESHOLD")); } move.cancel(); motionController.disable(); motionController.reset(); runOnce = false; }

Target:
public void end() { try { angle = motionController.getInputSafely(); } catch (InvalidSensorException e) { angle = 0; updateStatusFail(CHECK_NAME, e); } if (Math.abs(motionController.getSetpoint() - angle) > errorThreshold) { updateStatusFail(CHECK_NAME, new Exception("ANGLE TURNED NOT WITHIN ERROR THRESHOLD")); } move.cancel(); motionController.disable(); motionController.reset(); runOnce = false; outputStatuses(); }
Source:
public CurrentlyPlaying createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } final Builder builder = new CurrentlyPlaying.Builder() .setContext( hasAndNotNull(jsonObject, "context") ? new Context.JsonUtil().createModelObject( jsonObject.getAsJsonObject("context")) : null) .setTimestamp( hasAndNotNull(jsonObject, "timestamp") ? jsonObject.get("timestamp").getAsLong() : null) .setProgress_ms( hasAndNotNull(jsonObject, "progress_ms") ? jsonObject.get("progress_ms").getAsInt() : null) .setIs_playing( hasAndNotNull(jsonObject, "is_playing") ? jsonObject.get("is_playing").getAsBoolean() : null) .setCurrentlyPlayingType( hasAndNotNull(jsonObject, "currently_playing_type") ? CurrentlyPlayingType.keyOf( jsonObject.get("currently_playing_type").getAsString().toLowerCase()) : null) .setActions( hasAndNotNull(jsonObject, "actions") ? new Actions.JsonUtil().createModelObject( jsonObject.getAsJsonObject("actions")) : null); return builder .setItem( hasAndNotNull(jsonObject, "item") && builder.currentlyPlayingType != null ? builder.currentlyPlayingType == CurrentlyPlayingType.TRACK ? new Track.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item")) : builder.currentlyPlayingType == CurrentlyPlayingType.EPISODE ? new Episode.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item")) : null : null) .build(); }

Target:
public CurrentlyPlaying createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } return new CurrentlyPlaying.Builder() .setContext( hasAndNotNull(jsonObject, "context") ? new Context.JsonUtil().createModelObject( jsonObject.getAsJsonObject("context")) : null) .setTimestamp( hasAndNotNull(jsonObject, "timestamp") ? jsonObject.get("timestamp").getAsLong() : null) .setProgress_ms( hasAndNotNull(jsonObject, "progress_ms") ? jsonObject.get("progress_ms").getAsInt() : null) .setIs_playing( hasAndNotNull(jsonObject, "is_playing") ? jsonObject.get("is_playing").getAsBoolean() : null) .setItem( hasAndNotNull(jsonObject, "item") && hasAndNotNull(jsonObject, "currently_playing_type") ? (jsonObject.get("currently_playing_type").getAsString().equals("track") ? new Track.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item")) : jsonObject.get("currently_playing_type").getAsString().equals("episode") ? new Episode.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item")) : null) : null) .setCurrentlyPlayingType( hasAndNotNull(jsonObject, "currently_playing_type") ? CurrentlyPlayingType.keyOf( jsonObject.get("currently_playing_type").getAsString().toLowerCase()) : null) .setActions( hasAndNotNull(jsonObject, "actions") ? new Actions.JsonUtil().createModelObject( jsonObject.getAsJsonObject("actions")) : null) .build(); }
Source:
private LongTaskTimer(Registry registry, Id id) { this.clock = registry.clock(); this.id = id; PolledGauge.using(registry) .withId(id) .withTag(Statistic.activeTasks) .monitor(this, LongTaskTimer::activeTasks); PolledGauge.using(registry) .withId(id) .withTag(Statistic.duration) .monitor(this, t -> t.duration() / NANOS_PER_SECOND); }

Target:
private LongTaskTimer(Registry registry, Id id) { this.clock = registry.clock(); this.id = id; }
Source:
public boolean supportsCredentialType(String credentialType) { return credentialType == null || credentialType.equals(CredentialModel.PASSWORD); }

Target:
public boolean supportsCredentialType(String credentialType) { return credentialType.equals(getType()); }
Source:
public boolean setAlarms(final String deviceId, final long accountId, final long lastUpdatedAt, final List<Alarm> alarms, final DateTimeZone userTimeZone){ final Map<String, AttributeValueUpdate> items = generateAlarmUpdateItem(alarms, userTimeZone); if(items.isEmpty() || items.containsKey(EXPECTED_RING_TIME_ATTRIBUTE_NAME) == false){ return false; } final UpdateItemRequest request = generateUpdateRequest(deviceId, accountId, items); final HashMap<String, ExpectedAttributeValue> expected = new HashMap<>(); expected.put(UPDATED_AT_ATTRIBUTE_NAME, new ExpectedAttributeValue() .withComparisonOperator(ComparisonOperator.EQ) .withValue(new AttributeValue().withN(String.valueOf(lastUpdatedAt)))); expected.put(EXPECTED_RING_TIME_ATTRIBUTE_NAME, new ExpectedAttributeValue() .withComparisonOperator(ComparisonOperator.NE) .withValue(items.get(EXPECTED_RING_TIME_ATTRIBUTE_NAME).getValue()) ); request.withExpected(expected); try { final UpdateItemResult result = this.dynamoDBClient.updateItem(request); }catch (ConditionalCheckFailedException conditionalCheckFailedException){ LOGGER.warn("Cannot update alarm for device {}, account {}, last updated at {}", deviceId, accountId, lastUpdatedAt); return false; } return true; }

Target:
public boolean setAlarms(final String deviceId, final long accountId, final long lastUpdatedAt, final List<Alarm> alarms, final DateTimeZone userTimeZone){ final Map<String, AttributeValueUpdate> items = generateAlarmUpdateItem(alarms, userTimeZone); if(items.isEmpty() || !items.containsKey(EXPECTED_RING_TIME_ATTRIBUTE_NAME)){ return false; } final UpdateItemRequest request = generateUpdateRequest(deviceId, accountId, items); final HashMap<String, ExpectedAttributeValue> expected = new HashMap<>(); expected.put(UPDATED_AT_ATTRIBUTE_NAME, new ExpectedAttributeValue() .withComparisonOperator(ComparisonOperator.EQ) .withValue(new AttributeValue().withN(String.valueOf(lastUpdatedAt)))); expected.put(EXPECTED_RING_TIME_ATTRIBUTE_NAME, new ExpectedAttributeValue() .withComparisonOperator(ComparisonOperator.NE) .withValue(items.get(EXPECTED_RING_TIME_ATTRIBUTE_NAME).getValue()) ); request.withExpected(expected); try { final UpdateItemResult result = this.dynamoDBClient.updateItem(request); }catch (ConditionalCheckFailedException conditionalCheckFailedException){ LOGGER.warn("Cannot update alarm for device {}, account {}, last updated at {}", deviceId, accountId, lastUpdatedAt); return false; } return true; }
Source:
public void loginShouldReturnDetailedUserDto() throws UserNotFoundException { given(userRepository.findByUserNameAndUserPassword(USER_NAME, USER_PASSWORD)).willReturn(userEntity); UserDTO result = userService.login(userDTO); assertThat(result, notNullValue()); assertThat(result, is(detailedUserDTO)); }

Target:
public void loginShouldReturnDetailedUserDto() throws UserNotFoundException { given(userRepository.findByUserNameAndUserPassword(USER_NAME, USER_PASSWORD)).willReturn(userEntity); UserDTO result = userService.login(userDTO); then(modelMapper).should().map(userEntity, UserDTO.class); then(userRepository).should().findByUserNameAndUserPassword(USER_NAME, USER_PASSWORD); assertThat(result, is(detailedUserDTO)); }
Source:
protected void cleanupTestData() throws Exception { Session s = openSession(); s.beginTransaction(); try { s.createQuery("delete from java.lang.Object").executeUpdate(); s.getTransaction().commit(); } finally { s.close(); } }

Target:
protected void cleanupTestData() throws Exception { doInHibernate(this::sessionFactory, s -> { s.createQuery("delete from java.lang.Object").executeUpdate(); }); }
Source:
protected void initWorkspacePluginsState(ILaunchConfiguration configuration) throws CoreException { Map<IPluginModelBase, String> map = BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS); fPluginTreeViewer.setSubtreeChecked(fWorkspacePlugins, false); for (Entry<IPluginModelBase, String> entry : map.entrySet()) { IPluginModelBase model = entry.getKey(); if (fPluginTreeViewer.setChecked(model, true)) { setText(model, entry.getValue().toString()); } } fNumWorkspaceChecked = map.size(); resetGroup(fWorkspacePlugins); fPluginTreeViewer.setChecked(fWorkspacePlugins, fNumWorkspaceChecked > 0); fPluginTreeViewer.setGrayed(fWorkspacePlugins, fNumWorkspaceChecked > 0 && fNumWorkspaceChecked < getWorkspaceModels().length); }

Target:
protected void initWorkspacePluginsState(ILaunchConfiguration configuration) throws CoreException { Map<IPluginModelBase, String> map = BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS); fPluginTreeViewer.setSubtreeChecked(fWorkspacePlugins, false); for (Entry<IPluginModelBase, String> entry : map.entrySet()) { IPluginModelBase model = entry.getKey(); if (fPluginTreeViewer.setChecked(model, true)) { setText(model, entry.getValue()); } } fNumWorkspaceChecked = map.size(); resetGroup(fWorkspacePlugins); fPluginTreeViewer.setChecked(fWorkspacePlugins, fNumWorkspaceChecked > 0); fPluginTreeViewer.setGrayed(fWorkspacePlugins, fNumWorkspaceChecked > 0 && fNumWorkspaceChecked < getWorkspaceModels().length); }
Source:
public boolean onKeyUp(int keyCode, KeyEvent event) { char keyPressed = (char) event.getUnicodeChar(); if (mAnswerField != null && !mAnswerField.isFocused()) { if (sDisplayAnswer) { if (keyPressed == '1' || keyCode == KeyEvent.KEYCODE_BUTTON_Y) { answerCard(EASE_1); return true; } if (keyPressed == '2' || keyCode == KeyEvent.KEYCODE_BUTTON_X) { answerCard(EASE_2); return true; } if (keyPressed == '3' || keyCode == KeyEvent.KEYCODE_BUTTON_B) { answerCard(EASE_3); return true; } if (keyPressed == '4' || keyCode == KeyEvent.KEYCODE_BUTTON_A) { answerCard(EASE_4); return true; } if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { answerCard(getDefaultEase()); return true; } } if (keyCode == KeyEvent.KEYCODE_BUTTON_Y || keyCode == KeyEvent.KEYCODE_BUTTON_X || keyCode == KeyEvent.KEYCODE_BUTTON_B || keyCode == KeyEvent.KEYCODE_BUTTON_A) { displayCardAnswer(); return true; } if (keyPressed == 'e') { editCard(); return true; } if (keyPressed == '*') { onMark(mCurrentCard); return true; } if (keyPressed == '-') { dismiss(DismissType.BURY_CARD); return true; } if (keyPressed == '=') { dismiss(DismissType.BURY_NOTE); return true; } if (keyPressed == '@') { dismiss(DismissType.SUSPEND_CARD); return true; } if (keyPressed == '!') { dismiss(DismissType.SUSPEND_NOTE); return true; } if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) { playSounds(true); return true; } if (keyPressed == 'z') { undo(); return true; } } return super.onKeyUp(keyCode, event); }

Target:
public boolean onKeyUp(int keyCode, KeyEvent event) { char keyPressed = (char) event.getUnicodeChar(); if (mAnswerField != null && !mAnswerField.isFocused()) { if (sDisplayAnswer) { if (keyPressed == '1' || keyCode == KeyEvent.KEYCODE_BUTTON_Y) { answerCard(EASE_1); return true; } if (keyPressed == '2' || keyCode == KeyEvent.KEYCODE_BUTTON_X) { answerCard(EASE_2); return true; } if (keyPressed == '3' || keyCode == KeyEvent.KEYCODE_BUTTON_B) { answerCard(EASE_3); return true; } if (keyPressed == '4' || keyCode == KeyEvent.KEYCODE_BUTTON_A) { answerCard(EASE_4); return true; } if (keyCode == KeyEvent.KEYCODE_SPACE || keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { answerCard(getDefaultEase()); return true; } } else { if (keyCode == KeyEvent.KEYCODE_BUTTON_Y || keyCode == KeyEvent.KEYCODE_BUTTON_X || keyCode == KeyEvent.KEYCODE_BUTTON_B || keyCode == KeyEvent.KEYCODE_BUTTON_A) { displayCardAnswer(); return true; } } if (keyPressed == 'e') { editCard(); return true; } if (keyPressed == '*') { onMark(mCurrentCard); return true; } if (keyPressed == '-') { dismiss(DismissType.BURY_CARD); return true; } if (keyPressed == '=') { dismiss(DismissType.BURY_NOTE); return true; } if (keyPressed == '@') { dismiss(DismissType.SUSPEND_CARD); return true; } if (keyPressed == '!') { dismiss(DismissType.SUSPEND_NOTE); return true; } if (keyPressed == 'r' || keyCode == KeyEvent.KEYCODE_F5) { playSounds(true); return true; } if (keyPressed == 'z') { undo(); return true; } } return super.onKeyUp(keyCode, event); }
Source:
private String printAllProperties() { StringBuilder s = new StringBuilder(); String[] propertyKeys = ref.getPropertyKeys(); List<String> mimeTypes = getTransformerMimeTypes(); String id = getTransformerPropertyString(Constants.SERVICE_ID); String value; for (String key : propertyKeys) { if (key.equals(MIME_TYPE)) continue; if (key.equals(Constants.SERVICE_ID)) continue; value = getTransformerPropertyString(key); s.append(MessageFormat.format("\n\t{0}: {1}", key, value)); } s.insert(0, MessageFormat.format("{0}: {1}\n\n\t", Constants.SERVICE_ID, id)); s.append(MessageFormat.format("\n\t{0}: {1}\n", MIME_TYPE, mimeTypes.remove(0))); s.append(printMimeTypes(mimeTypes)); return s.toString(); }

Target:
private String printAllProperties() { StringBuilder s = new StringBuilder(); String[] propertyKeys = ref.getPropertyKeys(); List<String> mimeTypes = getTransformerMimeTypes(); String id = getTransformerPropertyString(Constants.SERVICE_ID); String value; s.append(MessageFormat.format("{0}: {1}\n\n\t", Constants.SERVICE_ID, id)); for (String key : propertyKeys) { if (key.equals(MIME_TYPE) || key.equals(Constants.SERVICE_ID)) { continue; } value = getTransformerPropertyString(key); s.append(MessageFormat.format("\n\t{0}: {1}", key, value)); } s.append(MessageFormat.format("\n\t{0}s: {1}\n", MIME_TYPE, mimeTypes.remove(0))); s.append(printMimeTypes(mimeTypes)); return s.toString(); }
Source:
protected Void doInBackground(Void... arg0) { if (!Utils.isNetworkAvailable(contextWeakReference.get())) { message = contextWeakReference.get().getString(R.string.error_internet_connection); userRegistered = false; return null; } String language = Locale.getDefault().getLanguage(); String country = DeviceSettingsProvider.getUserCountryCode(); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(contextWeakReference.get()); String token = sharedPreferences.getString(Constants.TOKEN, Constants.NO_TOKEN); ServerAuthenticator authenticator = new ServerAuthenticator(username, password, token, CatrobatWebClient.INSTANCE.getClient(), FlavoredConstants.BASE_URL_HTTPS, (status, errorMessage) -> { message = errorMessage; userRegistered = false; }); authenticator.performCatrobatRegister(email, language, country, sharedPreferences.edit()); return null; }

Target:
protected Void doInBackground(Void... arg0) { Context context = contextWeakReference.get(); if (context == null) { return null; } if (!Utils.isNetworkAvailable(context)) { message = context.getString(R.string.error_internet_connection); userRegistered = false; return null; } String language = Locale.getDefault().getLanguage(); String country = DeviceSettingsProvider.getUserCountryCode(); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String token = sharedPreferences.getString(Constants.TOKEN, Constants.NO_TOKEN); ServerAuthenticator authenticator = new ServerAuthenticator(username, password, token, CatrobatWebClient.INSTANCE.getClient(), FlavoredConstants.BASE_URL_HTTPS, sharedPreferences.edit(), new ServerAuthenticator.TaskListener() { @Override public void onError(int statusCode, String errorMessage) { message = context.getString(R.string.error_internet_connection); userRegistered = false; } @Override public void onSuccess() { userRegistered = true; } }); authenticator.performCatrobatRegister(email, language, country); return null; }