auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public SCIMSearchResult<Group> searchWithPost(@RequestParam Map<String, String> requestParameters) { SCIMSearchResult<Group> scimSearchResult = scimGroupProvisioning.search(requestParameters.get("filter"), requestParameters.get("sortBy"), requestParameters.getOrDefault("sortOrder", "ascending"), Integer.parseInt(requestParameters.getOrDefault("count", "100")), Integer.parseInt(requestParameters.getOrDefault("startIndex", "1"))); return attributesRemovalHelper.removeSpecifiedAttributes(scimSearchResult, requestParameters); }

Target:
public SCIMSearchResult<Group> searchWithPost(@RequestParam Map<String, String> requestParameters) { SCIMSearchResult<Group> scimSearchResult = scimGroupProvisioning.search(requestParameters.get("filter"), requestParameters.get("sortBy"), requestParameters.getOrDefault("sortOrder", "ascending"), Integer.parseInt(requestParameters.getOrDefault("count", "" + SCIMSearchResult.MAX_RESULTS)), Integer.parseInt(requestParameters.getOrDefault("startIndex", "1"))); return attributesRemovalHelper.removeSpecifiedAttributes(scimSearchResult, requestParameters); }
Source:
public void run() { try { Thread.sleep(DELAY_MS); } catch (final InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while sleeping to simulate computation", e); } for (int i = 0; i < numberOfKeys; i++) { Integer value = 0; for (int j = 0; j < numberOfUpdates; j++) { parameterWorker.push(startKey + i, delta); value = parameterWorker.pull(startKey + i); } LOG.log(Level.INFO, "Current value associated with key {0} is {1}", new Object[]{startKey + i, value}); } }

Target:
public void run() { try { Thread.sleep(DELAY_MS); } catch (final InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while sleeping to simulate computation", e); } for (int i = 0; i < numberOfUpdates; i++) { for (int j = 0; j < numberOfKeys; j++) { parameterWorker.push(startKey + j, delta); final Integer value = parameterWorker.pull(startKey + j); LOG.log(Level.INFO, "Current value associated with key {0} is {1}", new Object[]{startKey + j, value}); } } }
Source:
public EmbeddableForeignKeyResultImpl( List<SqlSelection> sqlSelections, NavigablePath navigablePath, EmbeddableValuedModelPart embeddableValuedModelPart, String resultVariable, DomainResultCreationState creationState) { super( embeddableValuedModelPart.getEmbeddableTypeDescriptor(), navigablePath ); this.resultVariable = resultVariable; AtomicInteger atomicInteger = new AtomicInteger( 0 ); fetches = new ArrayList<>(); embeddableValuedModelPart.visitFetchables( fetchable -> { generateFetches( sqlSelections, navigablePath, creationState, atomicInteger, fetchable ); }, null ); }

Target:
public EmbeddableForeignKeyResultImpl( List<SqlSelection> sqlSelections, NavigablePath navigablePath, EmbeddableValuedModelPart embeddableValuedModelPart, String resultVariable, DomainResultCreationState creationState) { super( embeddableValuedModelPart.getEmbeddableTypeDescriptor(), navigablePath ); this.resultVariable = resultVariable; fetches = new ArrayList<>(); MutableInteger index = new MutableInteger( 0 ); embeddableValuedModelPart.visitFetchables( fetchable -> { generateFetches( sqlSelections, navigablePath, creationState, index, fetchable ); }, null ); }
Source:
private ExecutorManager createMultiExecutorManagerInstance( ExecutorLoader loader) throws ExecutorManagerException { Props props = new Props(); props.put(ExecutorManager.AZKABAN_USE_MULTIPLE_EXECUTORS, "true"); props.put(ExecutorManager.AZKABAN_QUEUEPROCESSING_ENABLED, "false"); loader.addExecutor("localhost", 12345); loader.addExecutor("localhost", 12346); return new ExecutorManager(props, loader, new AlerterHolder(props), new CommonMetrics(new MetricsManager(new MetricRegistry()))); }

Target:
private ExecutorManager createMultiExecutorManagerInstance( ExecutorLoader loader) throws ExecutorManagerException { Props props = new Props(); props.put(ExecutorManager.AZKABAN_USE_MULTIPLE_EXECUTORS, "true"); props.put(ExecutorManager.AZKABAN_QUEUEPROCESSING_ENABLED, "false"); loader.addExecutor("localhost", 12345); loader.addExecutor("localhost", 12346); return new ExecutorManager(props, loader, new AlerterHolder(props), new CommonMetrics(new MetricRegistry())); }
Source:
public LeasedConnection connect(URI uri, Properties properties) throws ConnectionException { Connection connection = ConnectionFactory.connect(uri, properties); LeasedConnection leasedConnection = BasicLeasedConnection.create(connection, createTimeBudget(properties)); return leasedConnection; }

Target:
public LeasedConnection connect(URI uri, Properties properties) throws ConnectionException { TimeBudget timeBudget = createTimeBudget(properties); Connection connection = ConnectionFactory.connect(uri, properties); LeasedConnection leasedConnection = BasicLeasedConnection.create(connection, timeBudget); return leasedConnection; }
Source:
public void checkUnpermittedUserLogins(Attribute loginAttribute) throws InternalErrorException, WrongAttributeValueException { if(loginAttribute == null) return; if (perunNamespaces == null) { perunNamespaces = BeansUtils.getAllPropertiesFromCustomConfiguration("perun-namespaces.properties"); } String unpermittedNames; if ((unpermittedNames = perunNamespaces.get(loginAttribute.getFriendlyName() + ":reservedNames")) != null) { List<String> unpermittedNamesList = Arrays.asList(unpermittedNames.split("\\s*,\\s*")); if (unpermittedNamesList.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } else { if (unpermittedNamesForUserLogins.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } }

Target:
public void checkUnpermittedUserLogins(Attribute loginAttribute) throws InternalErrorException, WrongAttributeValueException { if(loginAttribute == null) return; checkPerunNamespacesMap(); String unpermittedNames = perunNamespaces.get(loginAttribute.getFriendlyName() + ":reservedNames"); if (unpermittedNames != null) { List<String> unpermittedNamesList = Arrays.asList(unpermittedNames.split("\\s*,\\s*")); if (unpermittedNamesList.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } else { if (unpermittedNamesForUserLogins.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } }
Source:
public void testClearOptions() { VariantContextWriterBuilder vcwb = new VariantContextWriterBuilder().clearOptions(); vcwb = vcwb.setOption(Options.INDEX_ON_THE_FLY); final VariantContextWriterBuilder builder = new VariantContextWriterBuilder().clearOptions(); VariantContextWriter writer = builder.setOutputFile(vcf).build(); writer.close(); }

Target:
public void testClearOptions() { VariantContextWriterBuilder vcwb = new VariantContextWriterBuilder(); vcwb.clearOptions().setOption(Options.INDEX_ON_THE_FLY); final VariantContextWriterBuilder builder = new VariantContextWriterBuilder().clearOptions(); Assert.assertTrue(builder.options.isEmpty()); }
Source:
public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { int localOffset = (opcode == ByteOps.ISTORE) ? (offset + length) : offset; LocalVariableList.Item local = localVariables.pcAndIndexToLocal(localOffset, idx); Type localType; if (local != null) { localType = local.getType(); if (localType.getBasicFrameType() != type.getBasicFrameType()) { local = null; localType = null; } } else { localType = type; } switch (opcode) { case ByteOps.ILOAD: case ByteOps.RET: { machine.localArg(frame, idx); machine.localInfo(local != null); machine.auxType(type); break; } case ByteOps.ISTORE: { LocalItem item = (local == null) ? null : local.getLocalItem(); machine.popArgs(frame, type); machine.auxType(type); machine.localTarget(idx, localType, item); break; } case ByteOps.IINC: { LocalItem item = (local == null) ? null : local.getLocalItem(); machine.localArg(frame, idx); machine.localTarget(idx, localType, item); machine.auxType(type); machine.auxIntArg(value); machine.auxCstArg(CstInteger.make(value)); break; } default: { visitInvalid(opcode, offset, length); return; } } machine.run(frame, offset, opcode); }

Target:
public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { int localOffset = (opcode == ByteOps.ISTORE) ? (offset + length) : offset; LocalVariableList.Item local = localVariables.pcAndIndexToLocal(localOffset, idx); Type localType; if (local != null) { localType = local.getType(); if (localType.getBasicFrameType() != type.getBasicFrameType()) { local = null; localType = type; } } else { localType = type; } switch (opcode) { case ByteOps.ILOAD: case ByteOps.RET: { machine.localArg(frame, idx); machine.localInfo(local != null); machine.auxType(type); break; } case ByteOps.ISTORE: { LocalItem item = (local == null) ? null : local.getLocalItem(); machine.popArgs(frame, type); machine.auxType(type); machine.localTarget(idx, localType, item); break; } case ByteOps.IINC: { LocalItem item = (local == null) ? null : local.getLocalItem(); machine.localArg(frame, idx); machine.localTarget(idx, localType, item); machine.auxType(type); machine.auxIntArg(value); machine.auxCstArg(CstInteger.make(value)); break; } default: { visitInvalid(opcode, offset, length); return; } } machine.run(frame, offset, opcode); }
Source:
public boolean sizeIsZero() { return somestring.length == 0; }

Target:
public boolean sizeIsZero() { return somestring.length() == 0; }
Source:
public static boolean isText(File file) throws IOException { try (FileInputStream rafile = new FileInputStream(file)) { int count = 0; while (count++ < MAX_NB_BINARY_BYTES) { int val = rafile.read(); if (val == 0) { return false; } } } return true; }

Target:
public static boolean isText(File file) throws IOException { try (FileInputStream rafile = new FileInputStream(file)) { int count = 0; int val = rafile.read(); while ((count < MAX_NB_BINARY_BYTES) && (val >= 0)) { if (val == 0) { return false; } count++; val = rafile.read(); } } return true; }
Source:
private String contentType() { return String.format("%s; charset=%s", mimeType, charset); }

Target:
private String contentType() { return String.format("%s; charset=%s", mimeType, MimeUtility.quote(charset, HeaderTokenizer.MIME)); }
Source:
private ValuesWriter getDoubleValuesWriter(ColumnDescriptor path) { if (this.parquetProperties.isByteStreamSplitEnabled()) { return new ByteStreamSplitValuesWriter.DoubleByteStreamSplitValuesWriter(parquetProperties.getInitialSlabSize(), parquetProperties.getPageSizeThreshold(), parquetProperties.getAllocator()); } ValuesWriter fallbackWriter = new PlainValuesWriter(parquetProperties.getInitialSlabSize(), parquetProperties.getPageSizeThreshold(), parquetProperties.getAllocator()); return DefaultValuesWriterFactory.dictWriterWithFallBack(path, parquetProperties, getEncodingForDictionaryPage(), getEncodingForDataPage(), fallbackWriter); }

Target:
private ValuesWriter getDoubleValuesWriter(ColumnDescriptor path) { ValuesWriter fallbackWriter = null; if (this.parquetProperties.isByteStreamSplitEnabled()) { fallbackWriter = new ByteStreamSplitValuesWriter.DoubleByteStreamSplitValuesWriter(parquetProperties.getInitialSlabSize(), parquetProperties.getPageSizeThreshold(), parquetProperties.getAllocator()); } else { fallbackWriter = new PlainValuesWriter(parquetProperties.getInitialSlabSize(), parquetProperties.getPageSizeThreshold(), parquetProperties.getAllocator()); } return DefaultValuesWriterFactory.dictWriterWithFallBack(path, parquetProperties, getEncodingForDictionaryPage(), getEncodingForDataPage(), fallbackWriter); }
Source:
public void addPending(PendingResource resource) { synchronized (this) { if (pendingResources.containsKey(resource)) { PendingResource old = pendingResources.get(resource); log.warn("Clearing stale pending resource (host: {}, vm: {})", old, old.getHost(), old.getVm()); removeFromSetMap(resourcesByVm, old.getVm(), old); removeFromSetMap(resourcesByHost, old.getHost(), old); } log.debug("Adding pending resource (host: {}, vm: {})", resource, resource.getHost(), resource.getVm()); resourcesByVm.putIfAbsent(resource.getVm(), new HashSet<>()); resourcesByHost.putIfAbsent(resource.getHost(), new HashSet<>()); addToSetMap(resourcesByVm, resource.getVm(), resource); addToSetMap(resourcesByHost, resource.getHost(), resource); pendingResources.put(resource, resource); } }

Target:
public void addPending(PendingResource resource) { synchronized (this) { if (pendingResources.containsKey(resource)) { PendingResource old = pendingResources.get(resource); log.warn("Clearing stale pending resource (host: {}, vm: {})", old, old.getHost(), old.getVm()); removeFromSetMap(resourcesByVm, old.getVm(), old); removeFromSetMap(resourcesByHost, old.getHost(), old); } log.debug("Adding pending resource (host: {}, vm: {})", resource, resource.getHost(), resource.getVm()); addToSetMap(resourcesByVm, resource.getVm(), resource); addToSetMap(resourcesByHost, resource.getHost(), resource); pendingResources.put(resource, resource); } }
Source:
public static SingleThreadEventLoop.IoHandlerFactory newFactory(final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory) { ObjectUtil.checkNotNull(selectorProvider, "selectorProvider"); ObjectUtil.checkNotNull(selectStrategyFactory, "selectStrategyFactory"); return new SingleThreadEventLoop.IoHandlerFactory() { @Override public SingleThreadEventLoop.IoHandler newHandler() { return new NioHandler(selectorProvider, selectStrategyFactory.newSelectStrategy()); } }; }

Target:
public static IoHandlerFactory newFactory(final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory) { ObjectUtil.checkNotNull(selectorProvider, "selectorProvider"); ObjectUtil.checkNotNull(selectStrategyFactory, "selectStrategyFactory"); return new IoHandlerFactory() { @Override public IoHandler newHandler() { return new NioHandler(selectorProvider, selectStrategyFactory.newSelectStrategy()); } }; }
Source:
public int getAverageHeadwayForStop (String stop_id, LocalDate date, LocalTime from, LocalTime to) { List<Trip> tripsForStop = feed.getStopTimesForStop(stop_id).stream() .map(t -> feed.trips.get(t.b.a)) .filter(trip -> feed.services.get(trip.service_id).activeOn(date)) .collect(Collectors.toList()); return getStopHeadwayForTrips(stop_id, tripsForStop, from, to); }

Target:
public int getAverageHeadwayForStop (String stop_id, LocalDate date, LocalTime from, LocalTime to) { List<Trip> tripsForStop = getTripsForDate(stop_id, date); return getStopHeadwayForTrips(stop_id, tripsForStop, from, to); }
Source:
private void loadImageIfNecessary(final boolean isInLayoutPass) { int width = getWidth(); int height = getHeight(); boolean hasLayoutParams = getLayoutParams() != null; boolean isFullyWrapContent = hasLayoutParams && getLayoutParams().height == LayoutParams.WRAP_CONTENT && getLayoutParams().width == LayoutParams.WRAP_CONTENT; if (width == 0 && height == 0 && !isFullyWrapContent) { return; } if (TextUtils.isEmpty(mUrl)) { if (mImageContainer != null) { mImageContainer.cancelRequest(); mImageContainer = null; } setImageBitmap(null); return; } if (mImageContainer != null && mImageContainer.getRequestUrl() != null) { if (mImageContainer.getRequestUrl().equals(mUrl)) { return; } else { mImageContainer.cancelRequest(); setImageBitmap(null); } } int imageMaxWidth = hasLayoutParams && getLayoutParams().width == LayoutParams.WRAP_CONTENT ? 0 : width; int imageMaxHeight = hasLayoutParams && getLayoutParams().height == LayoutParams.WRAP_CONTENT ? 0 : height; ImageContainer newContainer = mImageLoader.get(mUrl, new ImageListener() { @Override public void onErrorResponse(VolleyError error) { if (mErrorImageId != 0) { setImageResource(mErrorImageId); } } @Override public void onResponse(final ImageContainer response, boolean isImmediate) { if (isImmediate && isInLayoutPass) { post(new Runnable() { @Override public void run() { onResponse(response, false); } }); return; } if (response.getBitmap() != null) { setImageBitmap(response.getBitmap()); } else if (mDefaultImageId != 0) { setImageResource(mDefaultImageId); } } }, imageMaxWidth, imageMaxHeight); mImageContainer = newContainer; }

Target:
void loadImageIfNecessary(final boolean isInLayoutPass) { int width = getWidth(); int height = getHeight(); boolean wrapWidth = false, wrapHeight = false; if (getLayoutParams() != null) { wrapWidth = getLayoutParams().width == LayoutParams.WRAP_CONTENT; wrapHeight = getLayoutParams().height == LayoutParams.WRAP_CONTENT; } boolean isFullyWrapContent = wrapWidth && wrapHeight; if (width == 0 && height == 0 && !isFullyWrapContent) { return; } if (TextUtils.isEmpty(mUrl)) { if (mImageContainer != null) { mImageContainer.cancelRequest(); mImageContainer = null; } setDefaultImageOrNull(); return; } if (mImageContainer != null && mImageContainer.getRequestUrl() != null) { if (mImageContainer.getRequestUrl().equals(mUrl)) { return; } else { mImageContainer.cancelRequest(); setDefaultImageOrNull(); } } int maxWidth = wrapWidth ? 0 : width; int maxHeight = wrapHeight ? 0 : height; ImageContainer newContainer = mImageLoader.get(mUrl, new ImageListener() { @Override public void onErrorResponse(VolleyError error) { if (mErrorImageId != 0) { setImageResource(mErrorImageId); } } @Override public void onResponse(final ImageContainer response, boolean isImmediate) { if (isImmediate && isInLayoutPass) { post(new Runnable() { @Override public void run() { onResponse(response, false); } }); return; } if (response.getBitmap() != null) { setImageBitmap(response.getBitmap()); } else if (mDefaultImageId != 0) { setImageResource(mDefaultImageId); } } }, maxWidth, maxHeight); mImageContainer = newContainer; }
Source:
public GenericRecord next() { try { return reader.read(null, in); } catch (IOException e) { throw new RuntimeException(e); } }

Target:
public GenericRecord next() { try { return reader.read( null, in); } catch (IOException e) { throw new RuntimeException("Failed to read more records", e); } }
Source:
public void concurrentModificationRealmObjects() { final Realm realm = looperThread.realm; Dog dog1 = new Dog(); dog1.setName("Dog 1"); Dog dog2 = new Dog(); dog2.setName("Dog 2"); realm.beginTransaction(); dog1 = realm.copyToRealm(dog1); dog2 = realm.copyToRealm(dog2); realm.commitTransaction(); final WeakReference<RealmObjectProxy> weakReference1 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog1); final WeakReference<RealmObjectProxy> weakReference2 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog2); looperThread.realm.handlerController.realmObjects.put(weakReference1, Boolean.TRUE); final CountDownLatch dogAddFromBg = new CountDownLatch(1); Iterator<Map.Entry<WeakReference<RealmObjectProxy>, Object>> iterator = looperThread.realm.handlerController.realmObjects.entrySet().iterator(); AtomicBoolean fireOnce = new AtomicBoolean(true); while (iterator.hasNext()) { Dog next = (Dog) iterator.next().getKey().get(); if (fireOnce.compareAndSet(true, false)) { new Thread() { @Override public void run() { looperThread.realm.handlerController.realmObjects.put(weakReference2, Boolean.TRUE); dogAddFromBg.countDown(); } }.start(); TestHelper.awaitOrFail(dogAddFromBg); } assertEquals("Dog 1", next.getName()); } looperThread.testComplete(); }

Target:
public void concurrentModificationRealmObjects() { RealmConfiguration config = configFactory.createConfiguration(); final Realm realm = Realm.getInstance(config); Dog dog1 = new Dog(); dog1.setName("Dog 1"); Dog dog2 = new Dog(); dog2.setName("Dog 2"); realm.beginTransaction(); dog1 = realm.copyToRealm(dog1); dog2 = realm.copyToRealm(dog2); realm.commitTransaction(); final WeakReference<RealmObjectProxy> weakReference1 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog1); final WeakReference<RealmObjectProxy> weakReference2 = new WeakReference<RealmObjectProxy>((RealmObjectProxy)dog2); realm.handlerController.realmObjects.put(weakReference1, Boolean.TRUE); final CountDownLatch dogAddFromBg = new CountDownLatch(1); Iterator<Map.Entry<WeakReference<RealmObjectProxy>, Object>> iterator = realm.handlerController.realmObjects.entrySet().iterator(); AtomicBoolean fireOnce = new AtomicBoolean(true); while (iterator.hasNext()) { Dog next = (Dog) iterator.next().getKey().get(); if (fireOnce.compareAndSet(true, false)) { new Thread() { @Override public void run() { realm.handlerController.realmObjects.put(weakReference2, Boolean.TRUE); dogAddFromBg.countDown(); } }.start(); TestHelper.awaitOrFail(dogAddFromBg); } assertEquals("Dog 1", next.getName()); assertFalse(iterator.hasNext()); } realm.close(); }
Source:
public void testGetAllAttachableDisksByPoolWithNoPermissionsFilterDisabled() { List<Disk> result = dao.getAllAttachableDisksByPoolId(null, PRIVILEGED_USER_ID, false); assertFullGetAllAttachableDisksByPoolId(result); }

Target:
public void testGetAllAttachableDisksByPoolWithNoPermissionsFilterDisabled() { List<Disk> result = dao.getAllAttachableDisksByPoolId(null, UNPRIVILEGED_USER_ID, false); assertFullGetAllAttachableDisksByPoolId(result); }
Source:
public Expr visitTimestampLiteral(Object ctx, Stack<Expr> stack, TimestampLiteral expr) throws TajoException { StringBuilder sb = new StringBuilder(); if (!isHiveCatalog) { DateValue dateValue = expr.getDate(); TimeValue timeValue = expr.getTime(); int dates = ExprAnnotator.dateToIntArray(dateValue.getYears(), dateValue.getMonths(), dateValue.getDays()); int times = ExprAnnotator.timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long julianTimestamp; if (timeValue.hasSecondsFraction()) { julianTimestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], times[3] * 1000); } else { julianTimestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], 0); } TimeMeta tm = new TimeMeta(); DateTimeUtil.toJulianTimeMeta(julianTimestamp, tm); TimeZone tz = TimeZone.getDefault(); DateTimeUtil.toUTCTimezone(tm, tz); sb.append("?").append(" )"); parameters.add(new Pair(Type.TIMESTAMP, new TimestampDatum(DateTimeUtil.toJulianTimestamp(tm)))); } else { sb.append("\"").append(expr.toString()).append("\""); } queries.push(sb.toString()); return expr; }

Target:
public Expr visitTimestampLiteral(Object ctx, Stack<Expr> stack, TimestampLiteral expr) throws TajoException { StringBuilder sb = new StringBuilder(); if (!isHiveCatalog) { DateValue dateValue = expr.getDate(); TimeValue timeValue = expr.getTime(); int dates = ExprAnnotator.dateToIntArray(dateValue.getYears(), dateValue.getMonths(), dateValue.getDays()); int times = ExprAnnotator.timeToIntArray(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds(), timeValue.getSecondsFraction()); long julianTimestamp; if (timeValue.hasSecondsFraction()) { julianTimestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], times[3] * 1000); } else { julianTimestamp = DateTimeUtil.toJulianTimestamp(dates[0], dates[1], dates[2], times[0], times[1], times[2], 0); } TimeMeta tm = new TimeMeta(); DateTimeUtil.toJulianTimeMeta(julianTimestamp, tm); TimeZone tz = TimeZone.getDefault(); DateTimeUtil.toUTCTimezone(tm, tz); sb.append("?").append(" )"); Timestamp timestamp = new Timestamp(DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp(tm))); parameters.add(new Pair(Type.TIMESTAMP, timestamp)); } else { sb.append("\"").append(expr.toString()).append("\""); } queries.push(sb.toString()); return expr; }
Source:
public void stopTimer() { if (timerChronometer != null) { timerChronometer.stop(); isStarted = false; } }

Target:
private void stopTimer() { if (timerChronometer != null) { timerChronometer.stop(); isStarted = false; } }
Source:
public boolean visit(Node node, Visitor visitor, Printer printer) { if (node instanceof ColsNode) { ColsNode cols = (ColsNode) node; printer.println().print("<div class=\"cols\">").indent(2); boolean open = false; for (Node n : cols.getChildren()) { if (n instanceof HeaderNode) { if (open) { printer.print("</div>"); } printer.println().print("<div class=\"col-3\">"); open = true; } n.accept(visitor); } if (open) { printer.print("</div>"); } printer.indent(-2).println().print("</div>").println(); return true; } return false; }

Target:
public boolean visit(Node node, Visitor visitor, Printer printer) { if (node instanceof ColsNode) { ColsNode cols = (ColsNode) node; printer.println().print("<div class=\"cols\">").indent(2); boolean open = false; for (Node n : cols.getChildren()) { if (n instanceof HeaderNode || n instanceof DivNode) { if (open) { printer.print("</div>"); } printer.println().print("<div class=\"col-3\">"); open = true; } n.accept(visitor); } if (open) { printer.print("</div>"); } printer.indent(-2).println().print("</div>").println(); return true; } return false; }
Source:
public static long currentTimeMillis(){ return (long) (System.currentTimeMillis() * TIME_MULTIPLIER); }

Target:
public static long currentTimeMillis(){ if (TIME_MULTIPLIER == DEFAULT_TIME_MULTIPLIER){ return System.currentTimeMillis(); } else { return (long) ( RECORDED_TIME + (System.currentTimeMillis() - RECORDED_TIME) * TIME_MULTIPLIER ); } }
Source:
public PlanNodeCostEstimate visitAggregation(AggregationNode node, Void context) { PlanNodeStatsEstimate aggregationStats = getStats(node); PlanNodeStatsEstimate sourceStats = getStats(node.getSource()); return new PlanNodeCostEstimate(sourceStats.getOutputSizeInBytes(), aggregationStats.getOutputSizeInBytes(), 0); }

Target:
public PlanNodeCostEstimate visitAggregation(AggregationNode node, Void context) { PlanNodeStatsEstimate aggregationStats = getStats(node); PlanNodeStatsEstimate sourceStats = getStats(node.getSource()); double cpuCost = sourceStats.getOutputSizeInBytes(node.getSource().getOutputSymbols()); double memoryCost = aggregationStats.getOutputSizeInBytes(node.getOutputSymbols()); return new PlanNodeCostEstimate(cpuCost, memoryCost, 0); }
Source:
private static boolean isBlockUnsafe(final World world, final int x, final int y, final int z) { return isBlockDamaging(world, x, y, z) || isBlockAboveAir(world, x, y, z); }

Target:
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z) { return isBlockDamaging(world, x, y, z) || isBlockAboveAir(world, x, y, z); }
Source:
private static String getIdAttribute(View element) { int id = element.getId(); if (id == View.NO_ID) { return null; } return ResourceIdUtil.getIdStringQuietly(element.getResources(), id); }

Target:
private static String getIdAttribute(View element) { int id = element.getId(); if (id == View.NO_ID) { return null; } return ResourcesUtil.getIdStringQuietly(element, element.getResources(), id); }
Source:
protected Optional<DataSource> getJNDIDataSource(Optional<String> name) { if(jndiCtx==null) return Optional.absent(); if(name.isPresent()) { try { Optional<DataSource> ds = Optional.of((DataSource)jndiCtx.lookup(name.get())); if(LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "JDBCLoaer using JNDI DataSource {0}", name.get()); } config.setDatasourceId(name.get()); return ds; } catch (NamingException ex) { if(LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, "Could not resolve JNDI name "+name.get()+" for JDBCLoader Database", ex); } return Optional.absent(); } } else { if(LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("No JNDI name given for JDBCLoader DB."); } return Optional.absent(); } }

Target:
protected Optional<DataSource> getJNDIDataSource(Optional<String> name) { if(jndiCtx==null) return Optional.absent(); if(name.isPresent()) { try { Optional<DataSource> ds = Optional.of((DataSource)jndiCtx.lookup(name.get())); if(LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "JDBCLoader using JNDI DataSource {0}", name.get()); } config.setDatasourceId(name.get()); return ds; } catch (NamingException ex) { if(LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, "Could not resolve JNDI name "+name.get()+" for JDBCLoader Database", ex); } return Optional.absent(); } } else { if(LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("No JNDI name given for JDBCLoader DB."); } return Optional.absent(); } }
Source:
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText("&Script name:"); fileText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); fileText.setLayoutData(gd); fileText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = new Label(container, SWT.NULL); label = new Label(container, SWT.NULL); label.setText("&Directory:"); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); containerText.setLayoutData(gd); containerText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); Button button = new Button(container, SWT.PUSH); button.setText("Browse"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleBrowse(); } }); initialize(); dialogChanged(); setControl(container); }

Target:
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText(Messages.getString("StapNewWizardPage.ScriptName")); fileText = new Text(container, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); fileText.setLayoutData(gd); fileText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = new Label(container, SWT.NULL); label = new Label(container, SWT.NULL); label.setText(Messages.getString("StapNewWizardPage.Directory")); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); containerText.setLayoutData(gd); containerText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); Button button = new Button(container, SWT.PUSH); button.setText(Messages.getString("StapNewWizardPage.Browse")); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleBrowse(); } }); initialize(); dialogChanged(); setControl(container); }
Source:
public ResultSet refresh() throws CouchbaseLiteException { if (_query == null) throw new IllegalStateException("_query variable is null"); try { C4QueryEnumerator newEnum = _c4enum.refresh(); return newEnum != null ? new ResultSet(_query, newEnum, _columnNames) : null; } catch (LiteCoreException e) { throw LiteCoreBridge.convertException(e); } }

Target:
public ResultSet refresh() throws CouchbaseLiteException { if (_query == null) throw new IllegalStateException("_query variable is null"); synchronized (getDatabase().getLock()) { try { C4QueryEnumerator newEnum = _c4enum.refresh(); return newEnum != null ? new ResultSet(_query, newEnum, _columnNames) : null; } catch (LiteCoreException e) { throw LiteCoreBridge.convertException(e); } } }
Source:
private List<VariantEntity> updateVariantEntitiesSampleNames(List<VariantEntity> variantEntities, Table<String, String, Map<String, String>> studyFileIdsToPositionSamples) { variantEntities = variantEntities.stream().map( variantEntity -> updateVariantEntitySampleNames(variantEntity, studyFileIdsToPositionSamples) ).collect(Collectors.toList()); return variantEntities; }

Target:
private List<VariantEntity> updateVariantEntitiesSampleNames(List<VariantEntity> variantEntities, Table<String, String, Map<String, String>> studyFileIdsToPositionSamples) { return variantEntities.stream().map( variantEntity -> updateVariantEntitySampleNames(variantEntity, studyFileIdsToPositionSamples) ).collect(Collectors.toList()); }
Source:
private String normalizeHostName(String hostname) { checkNotNull(hostname, "hostname"); if (hostname.isEmpty() || hostname.charAt(0) == '.') { throw new IllegalArgumentException("Hostname '" + hostname + "'not valid"); } hostname = ImmutableDomainWildcardMapping.normalize(checkNotNull(hostname, "hostname")); if (hostname.charAt(0) == '*') { return hostname.substring(1); } return hostname; }

Target:
private String normalizeHostName(String hostname) { checkNotNull(hostname, "hostname"); if (hostname.isEmpty() || hostname.charAt(0) == '.') { throw new IllegalArgumentException("Hostname '" + hostname + "' not valid"); } hostname = ImmutableDomainWildcardMapping.normalize(checkNotNull(hostname, "hostname")); if (hostname.charAt(0) == '*') { if (hostname.length() < 3 || hostname.charAt(1) != '.') { throw new IllegalArgumentException("Wildcard Hostname '" + hostname + "'not valid"); } return hostname.substring(1); } return hostname; }
Source:
public String getPreview() { StringBuilder bld= new StringBuilder(); bld.append("\n"); if (isEnabled(CleanUpConstants.USE_UNBOXING)) { bld.append("int i = integerObject;\n"); bld.append("char c = cObject;\n"); } else { bld.append("int i = integerObject.intValue();\n"); bld.append("char c = cObject.charValue();\n"); } return bld.toString(); }

Target:
public String getPreview() { StringBuilder bld= new StringBuilder(); bld.append("\n"); bld.append("Integer integerObject = Integer.MAX_VALUE;\n"); bld.append("Character cObject = Character.MAX_VALUE;\n"); bld.append("\n"); if (isEnabled(CleanUpConstants.USE_UNBOXING)) { bld.append("int i = integerObject;\n"); bld.append("char c = cObject;\n"); } else { bld.append("int i = integerObject.intValue();\n"); bld.append("char c = cObject.charValue();\n"); } return bld.toString(); }
Source:
private void moveCursorTo( long pageId, int offsetInPage ) throws IOException { if ( isEOF( pageId, offsetInPage ) ) { throw newEOFException( String.format( "EOF at { pageId: %d, offsetInPage: %d } %s", pageId, offsetInPage, describeCurrentPosition() ) ); } if ( cursor.getCurrentPageId() != pageId && !cursor.next( pageId ) ) { throw newEOFException( String.format( "Page cache EOF for { pageId: %d, offsetInPage: %d }", pageId, offsetInPage ) ); } }

Target:
private void moveCursorTo( long pageId, int offsetInPage ) throws IOException { if ( isEOF( pageId, offsetInPage ) ) { throw newCursorMoveEOFException( pageId, offsetInPage ); } if ( !cursor.next( pageId ) ) { throw newCursorMoveEOFException( pageId, offsetInPage ); } }
Source:
public void collect(int doc) throws IOException { final Map<String, Object> hit = newHashMapWithExpectedSize(fields.size()); for (String field : fields) { Object docValues = this.docValues.get(field); if (docValues instanceof BinaryDocValues) { hit.put(field, ((BinaryDocValues) docValues).get(doc).utf8ToString()); } else if (docValues instanceof NumericDocValues) { hit.put(field, ((NumericDocValues) docValues).get(doc)); } else { throw new UnsupportedOperationException("Unhandled docValues for field: " + field + " -> " + docValues); } } checkState(!hit.isEmpty(), "No values loaded from document for fields: %s", fields); hits.add(hit); }

Target:
public void collect(int doc) throws IOException { final Map<String, Object> hit = newHashMapWithExpectedSize(fields.size()); for (String field : fields) { Object docValues = this.docValues.get(field); if (docValues instanceof BinaryDocValues) { hit.put(field, ((BinaryDocValues) docValues).get(doc).utf8ToString()); } else if (docValues instanceof NumericDocValues) { hit.put(field, ((NumericDocValues) docValues).get(doc)); } else { throw new UnsupportedOperationException("Unhandled docValues for field: " + field + " -> " + docValues); } } if (!hit.keySet().containsAll(fields)) { throw new IllegalStateException(String.format("Missing fields on partially loaded document: %s", Sets.difference(fields, hit.keySet()))); } hits.add(hit); }
Source:
private SweepOutcome grabLocksAndRun(SingleLockService locks) throws InterruptedException { try { locks.lockOrRefresh(); if (locks.haveLocks()) { return runOnce(); } else { log.debug("Skipping sweep because sweep is running elsewhere."); return SweepOutcome.UNABLE_TO_ACQUIRE_LOCKS; } } catch (RuntimeException e) { specificTableSweeper.updateSweepErrorMetric(); log.error("Sweep failed", e); return SweepOutcome.ERROR; } }

Target:
private SweepOutcome grabLocksAndRun(SingleLockService locks) throws InterruptedException { try { locks.lockOrRefresh(); if (locks.haveLocks()) { return runOnce(); } else { log.debug("Skipping sweep because sweep is running elsewhere."); closeTableLockIfHeld(); return SweepOutcome.UNABLE_TO_ACQUIRE_LOCKS; } } catch (RuntimeException e) { specificTableSweeper.updateSweepErrorMetric(); log.error("Sweep failed", e); return SweepOutcome.ERROR; } }
Source:
protected void processParagraphChilds( final ParagraphRenderBox box ) { rawResult = box.getRawValue(); paragraphBounds.setRect( box.getX(), box.getY(), box.getWidth(), box.getHeight() ); overflowX = box.isBoxOverflowX(); overflowY = box.isBoxOverflowY(); final long contentAreaX1 = box.getContentAreaX1(); contentAreaX2 = box.getContentAreaX2(); RenderBox lineBox = (RenderBox) box.getFirstChild(); while ( lineBox != null ) { manualBreak = false; processTextLine( lineBox, contentAreaX1, contentAreaX2 ); if ( manualBreak ) { addLinebreak(); } else if ( lineBox.getNext() != null ) { if ( lineBox.getStaticBoxLayoutProperties().isPreserveSpace() == false ) { addSoftBreak(); } else { RenderableText renderableText = (RenderableText) lineBox.getFirstChild(); int wordSize = renderableText.getGlyphs().getSize(); int currentOffset = renderableText.getOffset(); int currentLength = renderableText.getLength(); if ( wordSize == currentOffset + currentLength ) { addSoftBreak(); } else { addEmptyBreak(); } } } lineBox = (RenderBox) lineBox.getNext(); } }

Target:
protected void processParagraphChilds( final ParagraphRenderBox box ) { rawResult = box.getRawValue(); paragraphBounds.setRect( box.getX(), box.getY(), box.getWidth(), box.getHeight() ); overflowX = box.isBoxOverflowX(); overflowY = box.isBoxOverflowY(); final long contentAreaX1 = box.getContentAreaX1(); contentAreaX2 = box.getContentAreaX2(); RenderBox lineBox = (RenderBox) box.getFirstChild(); while ( lineBox != null ) { manualBreak = false; processTextLine( lineBox, contentAreaX1, contentAreaX2 ); if ( manualBreak ) { addLinebreak(); } else if ( lineBox.getNext() != null ) { if ( lineBox.getStaticBoxLayoutProperties().isPreserveSpace() == false ) { addSoftBreak(); } else { RenderNode deepestLastChild = getDeepestLastChild( lineBox ); if ( deepestLastChild != null && deepestLastChild instanceof RenderableText ) { RenderableText renderableText = (RenderableText) deepestLastChild; int wordSize = renderableText.getGlyphs().getSize(); int currentOffset = renderableText.getOffset(); int currentLength = renderableText.getLength(); if ( wordSize == currentOffset + currentLength ) { addSoftBreak(); } else { addEmptyBreak(); } } else { addSoftBreak(); } } } lineBox = (RenderBox) lineBox.getNext(); } }
Source:
public static void deleteProject(final String projectName, boolean deleteResources, SWTWorkbenchBot bot) { WaitUtils.waitForJobs(); try { ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { } WaitUtils.waitForJobs(); closeSecondaryShells(bot); WaitUtils.waitForJobs(); if (!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) { return; } final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER); projectViewBot.setFocus(); SWTBotTree treeBot = projectViewBot.bot().tree(); SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName); SWTBotMenu contextMenu = treeItem.contextMenu("Delete"); contextMenu.click(); handleDeleteDialog(deleteResources, bot); WaitUtils.waitForJobs(); WaitUtils.waitUntil(new IWaitCondition() { @Override public boolean test() throws Exception { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project.exists()) { closeSecondaryShells(bot); treeItem.contextMenu("Refresh").click(); contextMenu.click(); handleDeleteDialog(deleteResources, bot); WaitUtils.waitForJobs(); } return !project.exists(); } @Override public String getFailureMessage() { return "Unable to delete project: " + projectName; } }); }

Target:
public static void deleteProject(final String projectName, boolean deleteResources, SWTWorkbenchBot bot) { WaitUtils.waitForJobs(); try { ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { } WaitUtils.waitForJobs(); closeSecondaryShells(bot); WaitUtils.waitForJobs(); if (!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) { return; } final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER); projectViewBot.setFocus(); SWTBotTree treeBot = projectViewBot.bot().tree(); SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName); SWTBotMenu contextMenu = treeItem.contextMenu("Delete"); contextMenu.click(); handleDeleteDialog(deleteResources, bot); WaitUtils.waitForJobs(); }
Source:
public void test_alias_generation_from_sample() throws Exception { DetailedSample sample = new DetailedSampleImpl(); sample.setAlias("BART_1273_Br_P_nn_1-1_D_1"); DetailedLibrary library = new DetailedLibraryImpl(); library.setSample(sample); LibraryType libraryType = new LibraryType(); libraryType.setDescription("Paired End"); library.setLibraryType(libraryType); LibraryStrategyType libraryStrategyType = new LibraryStrategyType(); libraryStrategyType.setName("AMPLICON"); library.setLibraryStrategyType(libraryStrategyType); LibraryDesignCode code = new LibraryDesignCode(); code.setCode("WG"); library.setLibraryDesignCode(code); assertThat(sut.generate((Library) library), is("BART_1273_Br_P_PE_300_WG")); }

Target:
public void test_alias_generation_from_sample() throws Exception { DetailedSample sample = new DetailedSampleImpl(); sample.setAlias("BART_1273_Br_P_nn_1-1_D_1"); DetailedLibrary library = new DetailedLibraryImpl(); library.setSample(sample); LibraryType libraryType = new LibraryType(); libraryType.setDescription("Paired End"); library.setLibraryType(libraryType); LibraryStrategyType libraryStrategyType = new LibraryStrategyType(); libraryStrategyType.setName("AMPLICON"); library.setLibraryStrategyType(libraryStrategyType); LibraryDesignCode code = new LibraryDesignCode(); code.setCode("WG"); library.setLibraryDesignCode(code); assertThat(sut.generate(library), is("BART_1273_Br_P_PE_300_WG")); }
Source:
protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); if(dataObjectValueTypeIsSupported(data)){ results.put(data.getString("geoAreaCode"), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",data.getString("valueType"))); } } return results; }

Target:
protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; }
Source:
boolean areRequiredNetworksAvailable(final List<VmNetworkInterface> vmNetworkInterfaces, final List<VdsNetworkInterface> allInterfacesForVds) { for (final VmNetworkInterface vmIf : vmNetworkInterfaces) { boolean found = false; for (final VdsNetworkInterface vdsIf : allInterfacesForVds) { if (StringUtils.equals(vmIf.getNetworkName(), vdsIf.getNetworkName())) { found = true; break; } } if (!found) { log.debug("VDS is not ok for running the VM as network is missing"); return false; } } return true; }

Target:
boolean areRequiredNetworksAvailable(final List<VmNetworkInterface> vmNetworkInterfaces, final List<VdsNetworkInterface> allInterfacesForVds) { for (final VmNetworkInterface vmIf : vmNetworkInterfaces) { boolean found = false; for (final VdsNetworkInterface vdsIf : allInterfacesForVds) { if (StringUtils.equals(vmIf.getNetworkName(), vdsIf.getNetworkName())) { found = true; break; } } if (!found) { return false; } } return true; }
Source:
public RangeSet<String> getDimensionRangeSet(String dimension) { if (!Objects.equals(getDimension(), dimension) || getExtractionFn() != null) { return null; } RangeSet<String> retSet = TreeRangeSet.create(); for (String value : values) { retSet.add(Range.singleton(StringUtils.nullToEmptyNonDruidDataString(value))); } return retSet; }

Target:
public RangeSet<String> getDimensionRangeSet(String dimension) { if (!Objects.equals(getDimension(), dimension) || getExtractionFn() != null) { return null; } RangeSet<String> retSet = TreeRangeSet.create(); for (String value : values) { String valueEquivalent = NullHandling.nullToEmptyIfNeeded(value); if (valueEquivalent == null) { retSet.add(Range.lessThan("")); } else { retSet.add(Range.singleton(valueEquivalent)); } } return retSet; }
Source:
public String getPublicNote() { if (this.publicNote.startsWith(".PUBLIC.")) return publicNote; else return ""; }

Target:
public String getPublicNote() { if (this.publicNote.toUpperCase().startsWith(".PUBLIC.")) return publicNote; else return ""; }
Source:
public Dialog onCreateDialog(Bundle savedInstanceState) { initializeUiFields(); Log.d(TAG, "initialize correctly all the components"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if(changeIconTitleColor){ setIconsColor(iconColor); } stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP); if(showOKButtonByDefault) { ratingBar.setRating((float) defaultStarsSelected); } ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { if (rating >= 4.0) { rateMe.setVisibility(View.VISIBLE); noThanks.setVisibility(View.GONE); } else { noThanks.setVisibility(View.VISIBLE); rateMe.setVisibility(View.GONE); } } }); ratingBar.setRating((float) defaultStarsSelected); configureButtons(); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); RateMeDialogTimer.clearSharedPreferences(getActivity()); Log.d(TAG, "clear preferences"); } }); share.setVisibility(showShareButton ? View.VISIBLE : View.GONE); share.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(shareApp(appPackageName)); Log.d(TAG, "share App"); } }); return builder.setView(mView).setCustomTitle(tView).setCancelable(false).create(); }

Target:
public Dialog onCreateDialog(Bundle savedInstanceState) { initializeUiFields(); Log.d(TAG, "initialize correctly all the components"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); setIconsTitleColor(iconCloseColor, iconShareColor); stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP); if (showOKButtonByDefault) { ratingBar.setRating((float) defaultStarsSelected); } ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { if (rating >= 4.0) { rateMe.setVisibility(View.VISIBLE); noThanks.setVisibility(View.GONE); } else { noThanks.setVisibility(View.VISIBLE); rateMe.setVisibility(View.GONE); } } }); ratingBar.setRating((float) defaultStarsSelected); configureButtons(); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); RateMeDialogTimer.clearSharedPreferences(getActivity()); Log.d(TAG, "clear preferences"); } }); share.setVisibility(showShareButton ? View.VISIBLE : View.GONE); share.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(shareApp(appPackageName)); Log.d(TAG, "share App"); } }); return builder.setView(mView).setCustomTitle(tView).setCancelable(false).create(); }