before
stringlengths 14
203k
| after
stringlengths 37
104k
| repo
stringlengths 2
50
| type
stringclasses 1
value |
|---|---|---|---|
public Criteria andIdIn(List<Integer> values) {
if (values == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id in", values));
return (Criteria) this;
}
|
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id in", values));
</DeepExtract>
|
garbage-collection
|
positive
|
public static <T> void exportExcel(HttpServletResponse response, PageTableView<T> view, String name) throws Exception {
int lastPointIndex = name + ".xls".lastIndexOf(".");
addExportFilenameHeaders(response, name + ".xls".substring(0, lastPointIndex), name + ".xls".substring(lastPointIndex + 1, name + ".xls".length()));
response.setContentType(APPLICATION_VND_MS_EXCEL);
List<? extends Column> columns = view.getColumns();
Page<T> page = view.getData();
List<T> records = page.getRecords();
List<List<Object>> data = new ArrayList<>(records.size());
Map<String, Map<String, Object>> recordExtend = page.getExtension();
List<List<String>> headers = new ArrayList<>(columns.size());
columns.forEach(header -> headers.add(Collections.singletonList(header.getText())));
final Class<?> recordClass = records.get(0).getClass();
Field recordKeyField = ReflectionUtils.findField(recordClass, page.getItemKey());
recordKeyField.setAccessible(true);
final Map<String, Field> fieldMap = new HashMap<>(256);
records.forEach(record -> {
List<Object> objects = new ArrayList<>(columns.size());
columns.forEach(header -> {
Object fieldValue;
String fieldName = header.getModel();
try {
Field field = Optional.ofNullable(fieldMap.get(fieldName)).orElse(ReflectionUtils.findField(recordClass, header.getModel()));
field.setAccessible(true);
fieldValue = field.get(record);
fieldMap.put(fieldName, field);
} catch (IllegalAccessException | NullPointerException e) {
try {
Map<String, Object> singleRecordExtendData = recordExtend.get(recordKeyField.get(record).toString());
fieldValue = Objects.nonNull(singleRecordExtendData) ? singleRecordExtendData.get(fieldName) : null;
} catch (Exception ex) {
fieldValue = "not founded";
}
}
objects.add(fieldValue);
});
data.add(objects);
});
exportExcel(response, headers, data, name);
}
|
<DeepExtract>
int lastPointIndex = name + ".xls".lastIndexOf(".");
addExportFilenameHeaders(response, name + ".xls".substring(0, lastPointIndex), name + ".xls".substring(lastPointIndex + 1, name + ".xls".length()));
</DeepExtract>
|
citrus
|
positive
|
@Override
public void onExpansionToggled(boolean closing) {
super.onExpansionToggled(closing);
final int DOWN_ROTATION = 0;
final int UP_ROTATION = -540;
dropdownButton.animate().setDuration(false ? 0 : 400).rotation(closing ? DOWN_ROTATION : UP_ROTATION).setInterpolator(interpolator);
listDivider.setVisibility(closing ? VISIBLE : INVISIBLE);
}
|
<DeepExtract>
final int DOWN_ROTATION = 0;
final int UP_ROTATION = -540;
dropdownButton.animate().setDuration(false ? 0 : 400).rotation(closing ? DOWN_ROTATION : UP_ROTATION).setInterpolator(interpolator);
</DeepExtract>
|
Awful.apk
|
positive
|
public static ZonedDateTime getZonedDateTime(Struct source, String propertyName) {
if (CapStructHelper.getDate(source, propertyName) instanceof GregorianCalendar) {
return ((GregorianCalendar) CapStructHelper.getDate(source, propertyName)).toZonedDateTime();
}
if (CapStructHelper.getDate(source, propertyName) != null) {
throw new RuntimeException("Unsupported calendar class: " + CapStructHelper.getDate(source, propertyName).getClass().getName());
}
return null;
}
|
<DeepExtract>
if (CapStructHelper.getDate(source, propertyName) instanceof GregorianCalendar) {
return ((GregorianCalendar) CapStructHelper.getDate(source, propertyName)).toZonedDateTime();
}
if (CapStructHelper.getDate(source, propertyName) != null) {
throw new RuntimeException("Unsupported calendar class: " + CapStructHelper.getDate(source, propertyName).getClass().getName());
}
return null;
</DeepExtract>
|
coremedia-headless-server
|
positive
|
public T withData(String dataAttr, String value) {
setAttribute(Attr.DATA + "-" + dataAttr, value == null ? null : String.valueOf(value));
return self();
}
|
<DeepExtract>
setAttribute(Attr.DATA + "-" + dataAttr, value == null ? null : String.valueOf(value));
return self();
</DeepExtract>
|
j2html
|
positive
|
private void test(String inputFile, int nDataOptimizations, int expectedSavedBytes) throws IOException {
Assert.assertTrue(config.parseArgs(inputFile, "-do"));
Assert.assertTrue("Could not parse file " + inputFile, config.codeBaseParser.parseMainSourceFiles(config.inputFiles, code));
List<SourceConstant> labelsBefore = new ArrayList<>();
List<SourceConstant> labelsAfter = new ArrayList<>();
for (SourceFile f : code.getSourceFiles()) {
for (CodeStatement s : f.getStatements()) {
if (s.label != null && s.label.isLabel()) {
labelsBefore.add(s.label);
}
}
}
worker.work(code);
OptimizationResult r = config.optimizerStats;
for (SourceFile f : code.getSourceFiles()) {
for (CodeStatement s : f.getStatements()) {
if (s.label != null && s.label.isLabel()) {
labelsAfter.add(s.label);
}
}
}
Assert.assertEquals(labelsBefore.size(), labelsAfter.size());
Integer nOptimizations = r.optimizerSpecificStats.get(DataOptimizer.DATA_OPTIMIZER_OPTIMIZATIONS_CODE);
if (nOptimizations == null)
nOptimizations = 0;
Integer nPotentialBytes = r.optimizerSpecificStats.get(DataOptimizer.DATA_OPTIMIZER_POTENTIAL_BYTES_CODE);
if (nPotentialBytes == null)
nPotentialBytes = 0;
Assert.assertEquals("r.nDataOptimizations", nDataOptimizations, (int) nOptimizations);
Assert.assertEquals("r.nPotentialBytes", expectedSavedBytes, (int) nPotentialBytes);
}
|
<DeepExtract>
List<SourceConstant> labelsBefore = new ArrayList<>();
List<SourceConstant> labelsAfter = new ArrayList<>();
for (SourceFile f : code.getSourceFiles()) {
for (CodeStatement s : f.getStatements()) {
if (s.label != null && s.label.isLabel()) {
labelsBefore.add(s.label);
}
}
}
worker.work(code);
OptimizationResult r = config.optimizerStats;
for (SourceFile f : code.getSourceFiles()) {
for (CodeStatement s : f.getStatements()) {
if (s.label != null && s.label.isLabel()) {
labelsAfter.add(s.label);
}
}
}
Assert.assertEquals(labelsBefore.size(), labelsAfter.size());
Integer nOptimizations = r.optimizerSpecificStats.get(DataOptimizer.DATA_OPTIMIZER_OPTIMIZATIONS_CODE);
if (nOptimizations == null)
nOptimizations = 0;
Integer nPotentialBytes = r.optimizerSpecificStats.get(DataOptimizer.DATA_OPTIMIZER_POTENTIAL_BYTES_CODE);
if (nPotentialBytes == null)
nPotentialBytes = 0;
Assert.assertEquals("r.nDataOptimizations", nDataOptimizations, (int) nOptimizations);
Assert.assertEquals("r.nPotentialBytes", expectedSavedBytes, (int) nPotentialBytes);
</DeepExtract>
|
mdlz80optimizer
|
positive
|
@Test
public void testAnonymousClass() throws Exception {
CompilationUnit cu = compile("public class Foo {" + " public void bye() {}" + " abstract static class Scanner{ void hello(){} }" + " static final class DefaultScanner extends Scanner { void bye() {} } }");
final TypeDeclaration type = cu.getTypes().get(0);
final ClassOrInterfaceDeclaration extendingClass = (ClassOrInterfaceDeclaration) type.getMembers().get(2);
final MethodDeclaration method = (MethodDeclaration) extendingClass.getMembers().get(0);
assertMethods(method, Collections.<Method>emptyList());
}
|
<DeepExtract>
assertMethods(method, Collections.<Method>emptyList());
</DeepExtract>
|
javalang-compiler
|
positive
|
public Criteria andNameNotIn(List<String> values) {
if (values == null) {
throw new RuntimeException("Value for " + "name" + " cannot be null");
}
criteria.add(new Criterion("name not in", values));
return (Criteria) this;
}
|
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "name" + " cannot be null");
}
criteria.add(new Criterion("name not in", values));
</DeepExtract>
|
AnyMock
|
positive
|
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL);
data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);
Composite composite = createDefaultComposite(composite);
Label pathLabel = new Label(composite, SWT.NONE);
pathLabel.setText(PATH_TITLE);
Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
pathValueText.setText(((IResource) getElement()).getFullPath().toString());
Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
separator.setLayoutData(gridData);
Composite composite = createDefaultComposite(composite);
Label ownerLabel = new Label(composite, SWT.NONE);
ownerLabel.setText(OWNER_TITLE);
ownerText = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH);
ownerText.setLayoutData(gd);
try {
String owner = ((IResource) getElement()).getPersistentProperty(new QualifiedName("", OWNER_PROPERTY));
ownerText.setText((owner != null) ? owner : DEFAULT_OWNER);
} catch (CoreException e) {
ownerText.setText(DEFAULT_OWNER);
}
return composite;
}
|
<DeepExtract>
Composite composite = createDefaultComposite(composite);
Label pathLabel = new Label(composite, SWT.NONE);
pathLabel.setText(PATH_TITLE);
Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
pathValueText.setText(((IResource) getElement()).getFullPath().toString());
</DeepExtract>
<DeepExtract>
Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
separator.setLayoutData(gridData);
</DeepExtract>
<DeepExtract>
Composite composite = createDefaultComposite(composite);
Label ownerLabel = new Label(composite, SWT.NONE);
ownerLabel.setText(OWNER_TITLE);
ownerText = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH);
ownerText.setLayoutData(gd);
try {
String owner = ((IResource) getElement()).getPersistentProperty(new QualifiedName("", OWNER_PROPERTY));
ownerText.setText((owner != null) ? owner : DEFAULT_OWNER);
} catch (CoreException e) {
ownerText.setText(DEFAULT_OWNER);
}
</DeepExtract>
|
Composer-Eclipse-Plugin
|
positive
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.