auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
BaseBackupReceiver(Cache<Object, Object> cache) { this.cache = cache.getAdvancedCache(); this.cacheName = ByteString.fromString(cache.getName()); ComponentRegistry registry = this.cache.getComponentRegistry(); this.timeService = registry.getTimeService(); ExecutorService executor = registry.getComponent(ExecutorService.class, ASYNC_OPERATIONS_EXECUTOR); TransactionHandler txHandler = new TransactionHandler(cache); this.defaultHandler = new DefaultHandler(txHandler, executor); this.orderedHandler = new OrderedHandler(txHandler, executor); }

Target:
BaseBackupReceiver(Cache<Object, Object> cache) { this.cache = cache.getAdvancedCache(); this.cacheName = ByteString.fromString(cache.getName()); ComponentRegistry registry = this.cache.getComponentRegistry(); this.timeService = registry.getTimeService(); ExecutorService executor = registry.getComponent(ExecutorService.class, REMOTE_COMMAND_EXECUTOR); TransactionHandler txHandler = new TransactionHandler(cache); this.defaultHandler = new DefaultHandler(txHandler, executor); this.asyncBackupHandler = new AsyncBackupHandler(txHandler, executor); }
Source:
public int compare(LObject<T> lObject1, LObject<T> lObject2) { return ComparisonChain.start() .compare(calculator.getPriority(lObject1), calculator.getPriority(lObject2)) .result(); }

Target:
public int compare(LObject<T> lObject1, LObject<T> lObject2) { return ((Double) calculator.getPriority(lObject1)).compareTo(calculator.getPriority(lObject2)); }
Source:
private ChangeRecord getRecordForPath(String path) throws KeeperException.NoNodeException { ChangeRecord lastChange = null; synchronized (zks.getOutstandingChanges()) { lastChange = zks.getOutstandingChangesForPath().get(path); if (lastChange == null) { DataNode n = zks.getZKDatabase().getNode(path); if (n != null) { Set<String> children; synchronized(n) { children = n.getChildren(); } lastChange = new ChangeRecord(-1, path, n.stat, children.size(), zks.getZKDatabase().aclForNode(n)); } } } if (lastChange == null || lastChange.stat == null) { throw new KeeperException.NoNodeException(path); } return lastChange; }

Target:
private ChangeRecord getRecordForPath(String path) throws KeeperException.NoNodeException { ChangeRecord lastChange = null; synchronized (zks.outstandingChanges) { lastChange = zks.outstandingChangesForPath.get(path); if (lastChange == null) { DataNode n = zks.getZKDatabase().getNode(path); if (n != null) { Set<String> children; synchronized(n) { children = n.getChildren(); } lastChange = new ChangeRecord(-1, path, n.stat, children.size(), zks.getZKDatabase().aclForNode(n)); } } } if (lastChange == null || lastChange.stat == null) { throw new KeeperException.NoNodeException(path); } return lastChange; }
Source:
public List<String> toListFromKeywords(List<CcJudgmentKeyword> keywords) { if(keywords == null) keywords = Collections.emptyList(); List<String> list = keywords.stream() .map(CcJudgmentKeyword::getPhrase) .collect(Collectors.toList()); return list; }

Target:
public List<String> toListFromKeywords(List<CcJudgmentKeyword> keywords) { if(keywords == null) { keywords = Collections.emptyList(); } List<String> list = keywords.stream() .map(CcJudgmentKeyword::getPhrase) .collect(Collectors.toList()); return list; }
Source:
private void populateFieldInfosFromPojo(ColumnDefinitions rsMetaData) { fieldInfos = Lists.newArrayList(); Field[] fields = pojoClass.getDeclaredFields(); for (int i = 0; i < rsMetaData.size(); i++) { String columnName = rsMetaData.getName(i); String pojoField = getMatchingField(fields, columnName); if (pojoField != null && pojoField.length() != 0) { fieldInfos.add(new FieldInfo(columnName, pojoField, null)); } } }

Target:
private void populateFieldInfosFromPojo(ColumnDefinitions rsMetaData) { fieldInfos = Lists.newArrayList(); Field[] fields = pojoClass.getDeclaredFields(); for (int i = 0; i < rsMetaData.size(); i++) { String columnName = rsMetaData.getName(i); String pojoField = getMatchingField(fields, columnName); if (pojoField != null && pojoField.length() != 0) { fieldInfos.add(new FieldInfo(columnName, pojoField, null)); } else { LOG.error("Couldn't find corrosponding pojo field for column: " + columnName); } } }
Source:
@Override public String setCity(String city) { return city; }

Target:
public String setCity(String city) { return city; }
Source:
public static Options noProfileRunSubOptions() { Options options = new Options(); Arrays.asList(SIGNATURE_FILE, CONTAINER_SIGNATURE_FILE, EXTENSION_LIST, ARCHIVES, WEB_ARCHIVES, WEB_ARCHIVE_TYPES, RECURSIVE, QUIET).forEach( option -> options.addOption(option.newOption()) ); return options; }

Target:
public static Options noProfileRunSubOptions() { Options options = new Options(); Arrays.asList(SIGNATURE_FILE, CONTAINER_SIGNATURE_FILE, EXTENSION_LIST, ARCHIVES, ARCHIVE_TYPES, WEB_ARCHIVES, WEB_ARCHIVE_TYPES, RECURSIVE, QUIET).forEach( option -> options.addOption(option.newOption()) ); return options; }
Source:
private Map<String, AttributeValue> createPrimaryKey(String key) { Map<String, AttributeValue> k = new HashMap<String, AttributeValue>(); if (primaryKeyType == PrimaryKeyType.HASH) { k.put(primaryKeyName, new AttributeValue().withS(key)); } else if (primaryKeyType == PrimaryKeyType.HASH_AND_RANGE) { k = new HashMap<String, AttributeValue>(); k.put(hashKeyName, new AttributeValue().withS(hashKeyValue)); k.put(primaryKeyName, new AttributeValue().withS(key)); } else { throw new RuntimeException("Assertion Error: impossible primary key" + " type"); } return k; }

Target:
private Map<String, AttributeValue> createPrimaryKey(String key) { Map<String, AttributeValue> k = new HashMap<String, AttributeValue>(); if (primaryKeyType == PrimaryKeyType.HASH) { k.put(primaryKeyName, new AttributeValue().withS(key)); } else if (primaryKeyType == PrimaryKeyType.HASH_AND_RANGE) { k.put(hashKeyName, new AttributeValue().withS(hashKeyValue)); k.put(primaryKeyName, new AttributeValue().withS(key)); } else { throw new RuntimeException("Assertion Error: impossible primary key" + " type"); } return k; }
Source:
public static String implode(final String[] input) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < input.length; i++) { if (!isNull(input[i])) { builder.append(input[i]); } } return builder.toString(); }

Target:
public static String implode(final String[] input) { StringBuilder builder = new StringBuilder(); for (String character : input) { if (nonNull(character)) { builder.append(character); } } return builder.toString(); }
Source:
public String toString() { final StringBuilder sb = new StringBuilder("Transaction{"); sb.append("account=").append(account); sb.append(", invoice=").append(invoice); sb.append(", subscription='").append(subscription).append('\''); sb.append(", uuid='").append(uuid).append('\''); sb.append(", taxInCents=").append(taxInCents); sb.append(", currency='").append(currency).append('\''); sb.append(", description='").append(description).append('\''); sb.append(", recurring=").append(recurring); sb.append(", productCode=").append(productCode); sb.append(", createdAt=").append(createdAt); sb.append(", details=").append(details); sb.append(", paymentMethod=").append(paymentMethod); sb.append(", collectedAt=").append(collectedAt); sb.append(", updatedAt=").append(updatedAt); sb.append(", origin=").append(origin); sb.append(", gatewayType=").append(gatewayType); sb.append(", message=").append(message); sb.append(", failureType=").append(failureType); sb.append(", approvalCode=").append(approvalCode); sb.append('}'); return sb.toString(); }

Target:
public String toString() { final StringBuilder sb = new StringBuilder("Transaction{"); sb.append("account=").append(account); sb.append(", invoice=").append(invoice); sb.append(", subscription='").append(subscription).append('\''); sb.append(", uuid='").append(uuid).append('\''); sb.append(", taxInCents=").append(taxInCents); sb.append(", currency='").append(currency).append('\''); sb.append(", description='").append(description).append('\''); sb.append(", recurring=").append(recurring); sb.append(", productCode=").append(productCode); sb.append(", createdAt=").append(createdAt); sb.append(", details=").append(details); sb.append(", paymentMethod=").append(paymentMethod); sb.append(", collectedAt=").append(collectedAt); sb.append(", updatedAt=").append(updatedAt); sb.append(", origin=").append(origin); sb.append(", gatewayType=").append(gatewayType); sb.append(", message=").append(message); sb.append(", failureType=").append(failureType); sb.append(", approvalCode=").append(approvalCode); sb.append(", gatewayErrorCodes=").append(gatewayErrorCodes); sb.append('}'); return sb.toString(); }
Source:
public RestListWrapper<EchoParameter> getEchoParameters() { return new RestListWrapper<>( EchoParametersDao.getEchoParameters().stream().collect(Collectors.toList()), EchoParameter.class, this, "id", null); }

Target:
public RestListWrapper<EchoParameter> getEchoParameters() { return new RestListWrapper<>( EchoParametersDao.getEchoParameters(), EchoParameter.class, this, "id", null); }
Source:
public AvailabilityMode getAvailability() { if (distributionManager != null) { LocalTopologyManager localTopologyManager = cacheManager.getGlobalComponentRegistry().getComponent(LocalTopologyManager.class); return localTopologyManager.getCacheAvailability(name); } else { return AvailabilityMode.AVAILABLE; } }

Target:
public AvailabilityMode getAvailability() { if (partitionHandlingManager != null) { return partitionHandlingManager.getAvailabilityMode(); } else { return AvailabilityMode.AVAILABLE; } }
Source:
private void releaseExclusiveLock(String key) { InternalLockView lock = locks.get(key); if (lock != null && lock.getExclusive()) { locks.remove(key); log.debugFormat("The exclusive lock for key {0} is released and lock is removed from map", key); } else if (lock == null) { log.warnFormat("Trying to release exclusive lock which is not exist with for {0}", key); } else { log.warnFormat("Trying to release exclusive lock which is not exclusive lock for key {0}", key); } }

Target:
private void releaseExclusiveLock(String key) { InternalLockView lock = locks.get(key); if (lock != null && lock.getExclusive()) { locks.remove(key); log.debugFormat("The exclusive lock for key {0} is released and lock is removed from map", key); } else if (lock == null) { log.warnFormat("Trying to release exclusive lock which does not exist, lock key: {0}", key); } else { log.warnFormat("Trying to release exclusive lock but lock is not exclusive. lock key: {0}", key); } }
Source:
public static Node toNode(String data, String documentNS, Storage storage) throws SAXException { try { return toNode(new ByteArrayInputStream(data.getBytes("UTF-16")), Optional.of("UTF-16"), documentNS, storage); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }

Target:
public static Node toNode(String data, String documentNS, Storage storage) throws SAXException { try (ByteArrayInputStream bytes = new ByteArrayInputStream(data.getBytes("UTF-16"))) { return toNode(bytes, Optional.of("UTF-16"), documentNS, storage); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
Source:
public boolean getBoolean(int field) { checkFieldType(field, ImmutableSet.of(BOOLEAN)); return Boolean.valueOf(String.valueOf(getFieldValue(field))); }

Target:
public boolean getBoolean(int field) { checkFieldType(field, ImmutableSet.of(BOOLEAN)); return Boolean.parseBoolean(getFieldValue(field).toString()); }
Source:
public static void main(String... args) throws CheckstyleException { final JavadocPropertiesGenerator generator = new JavadocPropertiesGenerator(); final CommandLine cmd = new CommandLine(generator).setUsageHelpWidth(USAGE_HELP_WIDTH); try { final ParseResult parseResult = cmd.parseArgs(args); if (!CommandLine.printHelpIfRequested(parseResult)) { generator.writePropertiesFile(); } } catch (ParameterException ex) { System.err.println(ex.getMessage()); ex.getCommandLine().usage(System.err); } }

Target:
public static void main(String... args) throws CheckstyleException { final CliOptions cliOptions = new CliOptions(); final CommandLine cmd = new CommandLine(cliOptions).setUsageHelpWidth(USAGE_HELP_WIDTH); try { final ParseResult parseResult = cmd.parseArgs(args); if (parseResult.isUsageHelpRequested()) { cmd.usage(System.out); } else { writePropertiesFile(cliOptions); } } catch (ParameterException ex) { System.err.println(ex.getMessage()); ex.getCommandLine().usage(System.err); } }
Source:
public ITransformationFile getTransformationFile(String transformationId) { TransformFilesDTO transformDTO = (TransformFilesDTO) transformationDAO.getDTO(transformationId); String fileLocation = transformationFileService.getTransformFileLocation(); String absolutePatternFilePath = getAbsoluteFilePath(fileLocation, transformationId, transformDTO.getPatternFileName()); String absoluteMappingFilePath = getAbsoluteFilePath(fileLocation, transformationId, transformDTO.getMappingFileName()); TransformationFile transformFile = new TransformationFile(); transformFile.setAbsolutePatternFilePath(absolutePatternFilePath); transformFile.setAbsoluteMappingFilePath(absoluteMappingFilePath); transformFile.setTitle(transformDTO.getTitle()); transformFile.setDescription(transformDTO.getDescription()); transformFile.setPatternFileName(transformDTO.getPatternFileName()); transformFile.setPatternDescription(transformDTO.getMappingDescription()); transformFile.setPatternTitle(transformDTO.getPatternTitle()); transformFile.setMappingFileName(transformDTO.getMappingFileName()); transformFile.setMappingDescription(transformDTO.getMappingDescription()); transformFile.setMappingTitle(transformDTO.getMappingTitle()); transformFile.setUserName(transformDTO.getUserName()); return transformFile; }

Target:
public ITransformationFile getTransformationFile(String transformationId) { TransformFilesDTO transformDTO = (TransformFilesDTO) transformationDAO.getDTO(transformationId); String fileLocation = transformationFileService.getTransformFileLocation(); String absolutePatternFilePath = transformationFileService.getAbsoluteFilePath(fileLocation, transformationId, transformDTO.getPatternFileName()); String absoluteMappingFilePath = transformationFileService.getAbsoluteFilePath(fileLocation, transformationId, transformDTO.getMappingFileName()); ITransformationFile transformFile = transformationMapper.getTransformFile(transformDTO); transformFile.setAbsolutePatternFilePath(absolutePatternFilePath); transformFile.setAbsoluteMappingFilePath(absoluteMappingFilePath); return transformFile; }
Source:
public boolean tryDelete(OBonsaiCollectionPointer collectionPointer, long delay) { final CacheKey cacheKey = new CacheKey(storage, collectionPointer); final Object lock = treesSubsetLock(cacheKey); synchronized (lock) { SBTreeBonsaiContainer container = treeCache.getQuietly(cacheKey); assert container != null; if (container.usagesCounter != 0 || container.lastAccessTime > System.currentTimeMillis() - delay) { return false; } treeCache.remove(cacheKey); } OSBTreeBonsai<OIdentifiable, Integer> treeBonsai = this.loadSBTree(collectionPointer); try { treeBonsai.delete(); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error during ridbag deletion"), e); } finally { this.releaseSBTree(collectionPointer); } return true; }

Target:
public boolean tryDelete(OBonsaiCollectionPointer collectionPointer, long delay) { final CacheKey cacheKey = new CacheKey(storage, collectionPointer); final Object lock = treesSubsetLock(cacheKey); synchronized (lock) { SBTreeBonsaiContainer container = treeCache.getQuietly(cacheKey); if (container != null && (container.usagesCounter != 0 || container.lastAccessTime > System.currentTimeMillis() - delay)) { return false; } treeCache.remove(cacheKey); OSBTreeBonsai<OIdentifiable, Integer> treeBonsai = this.loadTree(collectionPointer); try { treeBonsai.delete(); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error during ridbag deletion"), e); } } return true; }
Source:
private static String valueToQuery(Type type, Object value) { if (type.equals(BIGINT)) { return String.valueOf(((long) value)); } if (type.equals(DoubleType.DOUBLE)) { return value.toString(); } if (type.equals(INTEGER)) { return String.valueOf(((Number) value).intValue()); } if (type.equals(SMALLINT)) { return String.valueOf(((Number) value).shortValue()); } if (type.equals(TINYINT)) { return String.valueOf(((Number) value).byteValue()); } if (type.equals(RealType.REAL)) { return String.valueOf(intBitsToFloat(((Number) value).intValue())); } if (type.equals(BOOLEAN)) { return String.valueOf(value); } if (type.equals(DATE)) { return "`" + FORMATTER.print(DAYS.toMillis((long) value)) + "`"; } if (type.equals(TimestampType.TIMESTAMP)) { return String.valueOf((long) value); } if (type.equals(VarcharType.VARCHAR)) { return "'" + ((Slice) value).toStringUtf8() + "'"; } if (type instanceof DecimalType) { if (Decimals.isLongDecimal(type)) { return Decimals.toString((Slice) value, ((DecimalType) type).getScale()); } return Decimals.toString((long) value, ((DecimalType) type).getScale()); } return "'" + ((Slice) value).toStringUtf8() + "'"; }

Target:
private static String valueToQuery(Type type, Object value) { if (type.equals(BIGINT)) { return String.valueOf(((Number) value).longValue()); } if (type.equals(INTEGER)) { return String.valueOf(((Number) value).intValue()); } if (type.equals(SMALLINT)) { return String.valueOf(((Number) value).shortValue()); } if (type.equals(TINYINT)) { return String.valueOf(((Number) value).byteValue()); } if (type.equals(BOOLEAN)) { return String.valueOf(value); } if (type.equals(DATE)) { return "`" + FORMATTER.print(DAYS.toMillis((long) value)) + "`"; } if (type.equals(VarcharType.VARCHAR)) { return "'" + ((Slice) value).toStringUtf8() + "'"; } if (type instanceof DecimalType) { if (Decimals.isLongDecimal(type)) { return Decimals.toString((Slice) value, ((DecimalType) type).getScale()); } return Decimals.toString((long) value, ((DecimalType) type).getScale()); } return "'" + ((Slice) value).toStringUtf8() + "'"; }
Source:
public HighTrustGPSLocalizer(){ buggyFrameGpsX = 0.0; buggyFrameGpsY = 0.0; buggyFrameRotZ = 0.0; lastEncoderReading = 0.0; posePub = new Publisher(NodeChannel.POSE.getMsgPath()); mostRecentUpdate = new Date(); new Subscriber(NodeChannel.GPS.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { GpsMeasurement newGPSData = (GpsMeasurement)m; synchronized (this) { long dt = newGPSData.getTimestamp().getTime() - mostRecentUpdate.getTime(); if(dt > 0.0){ buggyFrameGpsY = newGPSData.getLatitude(); buggyFrameGpsX = newGPSData.getLongitude(); publishUpdate(); mostRecentUpdate = newGPSData.getTimestamp(); } } } }); new Subscriber(NodeChannel.IMU_ANG_POS.getMsgPath(), ((topicName, m) -> { IMUAngularPositionMessage mes = ((IMUAngularPositionMessage) m); double y = mes.getRot()[0][1]; double x = mes.getRot()[0][0]; buggyFrameRotZ = Math.toDegrees(Math.atan2(y, x)); publishUpdate(); })); new Subscriber(NodeChannel.ENCODER.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { EncoderMeasurement measurement = (EncoderMeasurement) m; double currentEncoderMeasurement = measurement.getDistance(); double deltaDistance = currentEncoderMeasurement - lastEncoderReading; double deltaMeters = deltaDistance; LocTuple deltaPos = LocalizerUtil.convertMetersToLatLng(deltaMeters, buggyFrameRotZ); buggyFrameGpsY += deltaPos.getLatitude(); buggyFrameGpsX += deltaPos.getLongitude(); lastEncoderReading = currentEncoderMeasurement; publishUpdate(); } }); }

Target:
public HighTrustGPSLocalizer(){ buggyFrameGpsX = 0.0; buggyFrameGpsY = 0.0; buggyFrameRotZ = 0.0; lastEncoderReading = 0.0; posePub = new Publisher(NodeChannel.POSE.getMsgPath()); mostRecentUpdate = new Date(); new Subscriber(NodeChannel.GPS.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { GpsMeasurement newGPSData = (GpsMeasurement)m; synchronized (this) { long dt = newGPSData.getTimestamp().getTime() - mostRecentUpdate.getTime(); if(dt > 0.0){ buggyFrameGpsY = newGPSData.getLatitude(); buggyFrameGpsX = newGPSData.getLongitude(); publishUpdate(); mostRecentUpdate = newGPSData.getTimestamp(); } } } }); new Subscriber(NodeChannel.IMU_ANG_POS.getMsgPath(), ((topicName, m) -> { IMUAngularPositionMessage mes = ((IMUAngularPositionMessage) m); double y = mes.getRot()[0][1]; double x = mes.getRot()[0][0]; buggyFrameRotZ = Util.normalizeAngleDeg(-Math.toDegrees(Math.atan2(y, x))+90); publishUpdate(); })); new Subscriber(NodeChannel.ENCODER.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { EncoderMeasurement measurement = (EncoderMeasurement) m; double currentEncoderMeasurement = measurement.getDistance(); double deltaDistance = currentEncoderMeasurement - lastEncoderReading; LocTuple deltaPos = LocalizerUtil.convertMetersToLatLng(deltaDistance, buggyFrameRotZ); buggyFrameGpsY += deltaPos.getLatitude(); buggyFrameGpsX += deltaPos.getLongitude(); lastEncoderReading = currentEncoderMeasurement; publishUpdate(); } }); }
Source:
private void initAboutPane() { aboutPanel = new VBox(); aboutPanel.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS); final Text title = new TextWithStyle(translate("About"), TITLE_CSS_CLASS); aboutPanel.getChildren().add(title); final GridPane gridPane = new GridPane(); gridPane.getStyleClass().add("grid"); gridPane.add(new TextWithStyle(translate("Name:"), CAPTION_TITLE_CSS_CLASS), 0, 0); gridPane.add(new Label(applicationName), 1, 0); gridPane.add(new TextWithStyle(translate("Version:"), CAPTION_TITLE_CSS_CLASS), 0, 1); gridPane.add(new Label(applicationVersion), 1, 1); gridPane.add(new TextWithStyle(translate("Git Revision:"), CAPTION_TITLE_CSS_CLASS), 0, 2); gridPane.add(new Label(applicationGitRevision), 1, 2); gridPane.add(new TextWithStyle(translate("Build Timestamp:"), CAPTION_TITLE_CSS_CLASS), 0, 3); gridPane.add(new Label(applicationBuildTimestamp), 1, 3); gridPane.setHgap(20); gridPane.setVgap(10); aboutPanel.getChildren().add(gridPane); }

Target:
private void initAboutPane() { aboutPanel = new VBox(); aboutPanel.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS); final Text title = new TextWithStyle(translate("About"), TITLE_CSS_CLASS); aboutPanel.getChildren().add(title); final GridPane gridPane = new GridPane(); gridPane.getStyleClass().add("grid"); gridPane.add(new TextWithStyle(translate("Name:"), CAPTION_TITLE_CSS_CLASS), 0, 0); gridPane.add(new Label(applicationName), 1, 0); gridPane.add(new TextWithStyle(translate("Version:"), CAPTION_TITLE_CSS_CLASS), 0, 1); gridPane.add(new Label(applicationVersion), 1, 1); gridPane.add(new TextWithStyle(translate("Git Revision:"), CAPTION_TITLE_CSS_CLASS), 0, 2); Hyperlink gitRevisionLink = new Hyperlink(applicationGitRevision); gitRevisionLink.setOnAction(event -> { try { URI uri = new URI("<LINK_0>" + applicationGitRevision); opener.open(uri); } catch (URISyntaxException e) { e.printStackTrace(); } } ); gridPane.add(gitRevisionLink, 1, 2); gridPane.add(new TextWithStyle(translate("Build Timestamp:"), CAPTION_TITLE_CSS_CLASS), 0, 3); gridPane.add(new Label(applicationBuildTimestamp), 1, 3); gridPane.setHgap(20); gridPane.setVgap(10); aboutPanel.getChildren().add(gridPane); }
Source:
private static boolean isStringParameter( @NonNull Expression expression, @NonNull JavaContext context) { if (expression instanceof StringLiteral) { return true; } else { JavaParser.ResolvedNode resolvedNode = context.resolve(expression); if (resolvedNode instanceof JavaParser.ResolvedField) { if (((JavaParser.ResolvedField) resolvedNode).getValue() instanceof String) { return true; } } } return false; }

Target:
private static boolean isStringParameter( @NonNull Expression expression, @NonNull JavaContext context) { if (expression instanceof StringLiteral) { return true; } else { ResolvedNode resolvedNode = context.resolve(expression); if (resolvedNode instanceof ResolvedField) { if (((ResolvedField) resolvedNode).getValue() instanceof String) { return true; } } } return false; }
Source:
private ConnectionFactory(DbProperties properties, String server, String user, String password) throws SQLException { this.server = server; this.user = user; this.password = password; this.properties = properties; ds = new BasicDataSource(); ds.setDriverClassName(this.properties.getDriverName()); ds.setUrl(this.server); ds.setUsername(this.user); ds.setPassword(this.password); ds.setDefaultAutoCommit(true); ds.setDefaultReadOnly(false); ds.setValidationQuery(this.properties.getValidationQuery()); ds.setMaxActive(1000); ds.setMaxActive(10000); }

Target:
private ConnectionFactory(DbProperties properties, String server, String user, String password) throws SQLException { this.server = server; this.user = user; this.password = password; this.properties = properties; ds = new BasicDataSource(); ds.setDriverClassName(this.properties.getDriverName()); ds.setUrl(this.server); ds.setUsername(this.user); ds.setPassword(this.password); ds.setDefaultAutoCommit(autocommit); ds.setDefaultReadOnly(readonly); ds.setValidationQuery(this.properties.getValidationQuery()); Connection con = null; try { con = getConnection(); maxconnections = properties.getMaximumConnections(con); } catch (SQLException e) { logger.warn( "Cannot fetch maximum connection allowed from database", e); } finally { con.close(); } ds.setMaxActive(maxconnections); ds.setMaxIdle(maxconnections); logger.info(this.toString()); }
Source:
private boolean checkIncludes(String include, String field) { String includeString = (include == null ? "" : include); ArrayList<String> includeSplit = new ArrayList(Arrays.asList(includeString.split(","))); return includeSplit.contains(field); }

Target:
private boolean checkIncludes(String include, String field) { String includeString = (include == null ? "" : include); List<String> includeSplit = Arrays.asList(includeString.split(",")); return includeSplit.contains(field); }
Source:
private void buildFullyQualifiedNameAsPrefix() { if (fullyQualifiedName.equals("")) fullyQualifiedNameAsPrefix = ""; else fullyQualifiedNameAsPrefix = fullyQualifiedName+"."; }

Target:
protected void buildFullyQualifiedNameAsPrefix() { fullyQualifiedNameAsPrefix = buildNameAsPrefix(fullyQualifiedName); }
Source:
public void switchToNewUser(String jwt, String url) { final Bundle reply = new Bundle(); final Intent i = new Intent(context, SalesforceSDKManager.getInstance().getLoginActivityClass()); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final Bundle options = SalesforceSDKManager.getInstance().getLoginOptions(jwt, url).asBundle(); i.putExtras(options); reply.putParcelable(AccountManager.KEY_INTENT, i); context.startActivity(i); }

Target:
public void switchToNewUser(String jwt, String url) { Bundle options = SalesforceSDKManager.getInstance().getLoginOptions(jwt, url).asBundle(); switchToNewUserWithOptions(options); }
Source:
public VaultPackage open(File pkg) throws IOException { try { return new ZipVaultPackage(pkg, false, true); } catch (IOException e) { log.error("Cloud not open file as ZipVaultPackage.", pkg.getPath(), e); return null; } }

Target:
public VaultPackage open(File pkg) throws IOException { try { return new ZipVaultPackage(pkg, false, true); } catch (IOException e) { log.error("Cloud not open file as ZipVaultPackage.", pkg.getPath(), e); throw e; } }
Source:
public DenseLocalDateDoubleTimeSeries mapValues(DoubleUnaryOperator mapper) { return of( startDate, Arrays.stream(points).map(d -> isValidPoint(d) ? mapper.applyAsDouble(d) : d), dateCalculation); }

Target:
public LocalDateDoubleTimeSeries mapValues(DoubleUnaryOperator mapper) { DoubleStream values = DoubleStream.of(points).map(d -> isValidPoint(d) ? applyMapper(mapper, d) : d); return new DenseLocalDateDoubleTimeSeries(startDate, values.toArray(), dateCalculation, true); }
Source:
public boolean hasNext() throws SQLException { if (_next) { return true; } else if (_needToClose || _closed) { return false; } if (_stmt == null) { return false; } _next = _rs.next(); if (!_next) { _rs.close(); _rs = _stmt.executeQuery(new SqlStringBuilder().append("HANDLER ") .appendIdent(_source.getTableName(), "Iterator") .append(" READ `PRIMARY` NEXT LIMIT ") .append(_bufSize) .toString()); _next = _rs.next(); if (!_next) { _needToClose = true; } } return _next; }

Target:
private boolean hasNext() throws SQLException { if (_isEof || _closed) { return false; } if (_next) { return true; } if (_stmt == null) { return false; } _next = _rs.next(); if (!_next) { _rs.close(); _rs = _stmt.executeQuery(new SqlStringBuilder().append("HANDLER ") .appendIdent(_source.getTableName(), "Iterator") .append(" READ `PRIMARY` NEXT LIMIT ") .append(_bufSize) .toString()); _next = _rs.next(); if (!_next) { _isEof = true; } } return _next; }
Source:
public RuntimeException translateException(Throwable throwable) { RuntimeException runtimeException = throwable instanceof RuntimeException ? (RuntimeException) throwable : new RuntimeException(throwable.getMessage(), throwable); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }

Target:
private RuntimeException translateException(Throwable throwable) { RuntimeException runtimeException = throwable instanceof RuntimeException ? (RuntimeException) throwable : new RuntimeException(throwable.getMessage(), throwable); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }
Source:
public void cleanup() { fModule.dispose(); fTrace.dispose(); CtfTmfTestTraceUtils.dispose(getTestTrace()); }

Target:
public void cleanup() { fModule.dispose(); CtfTmfTestTraceUtils.dispose(getTestTrace()); }
Source:
public void run() { if (!isStarted.compareAndSet(false, true)) { log.info("Attempting to start an already started job coordinator. "); return; } if (isJmxEnabled) { jmxServer = new JmxServer(); state.jmxUrl = jmxServer.getJmxUrl(); state.jmxTunnelingUrl = jmxServer.getTunnelingJmxUrl(); } else { jmxServer = null; } try { log.info("Starting Cluster Based Job Coordinator"); JobModel jobModel = jobModelManager.jobModel(); CheckpointManager checkpointManager = new TaskConfigJava(config).getCheckpointManager(metrics); if (checkpointManager != null) { checkpointManager.createStream(); } changelogStreamManager.createChangeLogStreams(jobModel.getConfig(), jobModel.maxChangeLogStreamPartitions); Map prevPartitionMappings = changelogStreamManager.readPartitionMapping(); changelogStreamManager.updatePartitionMapping(prevPartitionMappings, jobModel.getTaskPartitionMappings()); containerProcessManager.start(); systemAdmins.start(); partitionMonitor.start(); boolean isInterrupted = false; while (!containerProcessManager.shouldShutdown() && !checkAndThrowException() && !isInterrupted) { try { Thread.sleep(jobCoordinatorSleepInterval); } catch (InterruptedException e) { isInterrupted = true; log.error("Interrupted in job coordinator loop ", e); Thread.currentThread().interrupt(); } } } catch (Throwable e) { log.error("Exception thrown in the JobCoordinator loop ", e); throw new SamzaException(e); } finally { onShutDown(); } }

Target:
public void run() { if (!isStarted.compareAndSet(false, true)) { log.info("Attempting to start an already started job coordinator. "); return; } if (isJmxEnabled) { jmxServer = new JmxServer(); state.jmxUrl = jmxServer.getJmxUrl(); state.jmxTunnelingUrl = jmxServer.getTunnelingJmxUrl(); } else { jmxServer = null; } try { log.info("Starting Cluster Based Job Coordinator"); JobModel jobModel = jobModelManager.jobModel(); CheckpointManager checkpointManager = new TaskConfigJava(config).getCheckpointManager(metrics); if (checkpointManager != null) { checkpointManager.createResources(); } ChangelogStreamManager.createChangelogStreams(jobModel.getConfig(), jobModel.maxChangeLogStreamPartitions); Map prevPartitionMappings = changelogStreamManager.readPartitionMapping(); changelogStreamManager.updatePartitionMapping(prevPartitionMappings, jobModel.getTaskPartitionMappings()); containerProcessManager.start(); systemAdmins.start(); partitionMonitor.start(); boolean isInterrupted = false; while (!containerProcessManager.shouldShutdown() && !checkAndThrowException() && !isInterrupted) { try { Thread.sleep(jobCoordinatorSleepInterval); } catch (InterruptedException e) { isInterrupted = true; log.error("Interrupted in job coordinator loop ", e); Thread.currentThread().interrupt(); } } } catch (Throwable e) { log.error("Exception thrown in the JobCoordinator loop ", e); throw new SamzaException(e); } finally { onShutDown(); } }
Source:
public void testToNpyFormat() throws Exception { File dir = new File("C:\\DL4J\\Git\\dl4j-test-resources\\src\\main\\resources\\numpy_arrays"); File[] files = dir.listFiles(); for(File f : files){ if(!f.getPath().endsWith(".npy")){ log.warn("Skipping: {}", f); continue; } String path = f.getAbsolutePath(); int lastDot = path.lastIndexOf('.'); int lastUnderscore = path.lastIndexOf('_'); String dtype = path.substring(lastUnderscore+1, lastDot); System.out.println(path + " : " + dtype); DataType dt = DataType.fromNumpy(dtype); System.out.println(dt); INDArray arr = Nd4j.arange(12).castTo(dt).reshape(3,4); byte[] bytes = Nd4j.toNpyByteArray(arr); byte[] expected = FileUtils.readFileToByteArray(f); System.out.println(Arrays.toString(expected)); System.out.println(Arrays.toString(bytes)); for( int i=0; i<bytes.length; i++ ){ System.out.print((char)bytes[i]); } System.out.println(); for( int i=0; i<expected.length; i++ ){ System.out.print((char)expected[i]); } System.out.println("\n---------"); } }

Target:
public void testToNpyFormat() throws Exception { val dir = testDir.newFolder(); new ClassPathResource("numpy_arrays/").copyDirectory(dir); File[] files = dir.listFiles(); int cnt = 0; for(File f : files){ if(!f.getPath().endsWith(".npy")){ log.warn("Skipping: {}", f); continue; } String path = f.getAbsolutePath(); int lastDot = path.lastIndexOf('.'); int lastUnderscore = path.lastIndexOf('_'); String dtype = path.substring(lastUnderscore+1, lastDot); System.out.println(path + " : " + dtype); DataType dt = DataType.fromNumpy(dtype); INDArray arr = Nd4j.arange(12).castTo(dt).reshape(3,4); byte[] bytes = Nd4j.toNpyByteArray(arr); byte[] expected = FileUtils.readFileToByteArray(f); assertArrayEquals("Failed with file [" + f.getName() + "]", expected, bytes); cnt++; } assertTrue(cnt > 0); }
Source:
public void testRegexSequence() { String test1 = "123Test"; assertTrue(test1.matches(StringUtils.ALPHA_NUM_REGEXP)); String test2 = " Test"; assertFalse(test2.matches(StringUtils.ALPHA_NUM_REGEXP)); String test3 = "Test#"; assertFalse(test3.matches(StringUtils.ALPHA_NUM_REGEXP)); String test4 = "123Test"; assertTrue(test4.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); String test5 = " 123Test"; assertTrue(test5.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); String test6 = " 123Test#"; assertFalse(test6.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); }

Target:
public void testRegexSequence() { String test1 = "123Test"; assertTrue(test1.matches(StringUtils.ALPHA_NUM_REGEXP)); String test2 = "123Test "; assertFalse(test2.matches(StringUtils.ALPHA_NUM_REGEXP)); String test3 = "123Test #"; assertFalse(test3.matches(StringUtils.ALPHA_NUM_REGEXP)); String test4 = "123Test"; assertTrue(test4.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); String test5 = "123Test "; assertTrue(test5.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); String test6 = "123Test #"; assertFalse(test6.matches(StringUtils.ALPHA_NUM_SPACE_REGEXP)); }
Source:
public void shouldCallDeploymentTransformersWithEmptyCauseException() throws Exception { TestExceptionDeployThrower.shouldThrow = new DeploymentException("Could not handle ba", null); Mockito.when(serviceLoader.all(DeploymentExceptionTransformer.class)) .thenReturn(Collections.singletonList(transformer)); fire(new DeployDeployment( container, new Deployment(new DeploymentDescription("test", ShrinkWrap.create(JavaArchive.class)) .setExpectedException(DeploymentException.class)))); Mockito.verify(transformer, Mockito.times(1)).transform(Mockito.isA(Exception.class)); }

Target:
public void shouldCallDeploymentTransformersWithEmptyCauseException() throws Exception { TestExceptionDeployThrower.shouldThrow = new DeploymentException("Could not handle ba", null); Mockito.when(serviceLoader.all(DeploymentExceptionTransformer.class)) .thenReturn(Collections.singletonList(transformer)); fire(new DeployDeployment( container, new Deployment(new DeploymentDescription("test", ShrinkWrap.create(JavaArchive.class)) .setExpectedException(DeploymentException.class)))); Mockito.verify(transformer, Mockito.times(1)).transform(TestExceptionDeployThrower.shouldThrow); }
Source:
void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK3) { long context = OS.gtk_widget_get_style_context (handle); String css = "GtkWindow {background-color: rgb(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }

Target:
void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK3) { long context = OS.gtk_widget_get_style_context (handle); double alpha = (background.getAlpha() & 0xFFFF) / (float)0xFFFF; String css = "GtkWindow {background-color: rgba(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +", " + alpha + ");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }
Source:
public Map<String, String> getConfigMap(String configKey) { String configMap = config.get(configKey); try { List<StringPair> map = OBJECT_MAPPER.readValue(configMap, MAP_TYPE_REPRESENTATION); return map.stream().collect(Collectors.toMap(StringPair::getKey, StringPair::getValue)); } catch (IOException e) { throw new RuntimeException("Could not deserialize json: " + configMap, e); } }

Target:
public Map<String, String> getConfigMap(String configKey) { String configMap = config.get(configKey); try { List<StringPair> map = JsonSerialization.readValue(configMap, MAP_TYPE_REPRESENTATION); return map.stream().collect(Collectors.toMap(StringPair::getKey, StringPair::getValue)); } catch (IOException e) { throw new RuntimeException("Could not deserialize json: " + configMap, e); } }
Source:
protected void prepareOnAffectedNodes(TxInvocationContext ctx, PrepareCommand command, Collection<Address> recipients, boolean sync) { if (log.isTraceEnabled()) { log.tracef("Total Order Anycast transaction %s with Total Order", command.getGlobalTransaction().prettyPrint()); } if (!ctx.hasModifications()) { return; } if (!ctx.isOriginLocal()) { throw new IllegalStateException("Expected a local context while TO-Anycast prepare command"); } if (!(command instanceof VersionedPrepareCommand)) { throw new IllegalStateException("Expected a Versioned Prepare Command in version aware component"); } try { Set<Object> affectedKeys = getAffectedKeys(command); KeysValidateFilter responseFilter = affectedKeys == null || isSyncCommitPhase() ? null : new KeysValidateFilter(rpcManager.getAddress(), affectedKeys); setVersionsSeenOnPrepareCommand((VersionedPrepareCommand) command, ctx); totalOrderAnycastPrepare(recipients, command, responseFilter); if (responseFilter != null && !responseFilter.isAllKeysValidated()) { throw new CacheException("Not all keys were validated. Possible member has left the cluster"); } } finally { totalOrderTxPrepare(ctx); } }

Target:
protected void prepareOnAffectedNodes(TxInvocationContext ctx, PrepareCommand command, Collection<Address> recipients, boolean sync) { if (log.isTraceEnabled()) { log.tracef("Total Order Anycast transaction %s with Total Order", command.getGlobalTransaction().globalId()); } if (!ctx.hasModifications()) { return; } if (!ctx.isOriginLocal()) { throw new IllegalStateException("Expected a local context while TO-Anycast prepare command"); } if (!(command instanceof VersionedPrepareCommand)) { throw new IllegalStateException("Expected a Versioned Prepare Command in version aware component"); } try { KeysValidateFilter responseFilter = ctx.getCacheTransaction().hasModification(ClearCommand.class) || isSyncCommitPhase() ? null : new KeysValidateFilter(rpcManager.getAddress(), ctx.getAffectedKeys()); setVersionsSeenOnPrepareCommand((VersionedPrepareCommand) command, ctx); totalOrderAnycastPrepare(recipients, command, responseFilter); if (responseFilter != null && !responseFilter.isAllKeysValidated()) { throw new CacheException("Not all keys were validated. Possible member has left the cluster"); } } finally { totalOrderTxPrepare(ctx); } }
Source:
public void aggregate(ByteBuffer buf, int position) { ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); Object value = valueSelector.getObject(); long time = Long.MAX_VALUE; String firstString = null; if (value instanceof SerializablePairLongString) { SerializablePairLongString serializablePair = (SerializablePairLongString) value; time = serializablePair.lhs; firstString = serializablePair.rhs; } else if (value instanceof String) { time = timeSelector.getLong(); firstString = (String) value; } else if (value != null) { throw new IllegalStateException( "Try to aggregate unsuported class type [" + value.getClass().getName() + "]. Supported class types: String or SerializablePairLongString" ); } long lastTime = mutationBuffer.getLong(position); if (firstString != null && time < lastTime) { if (firstString.length() > maxStringBytes) { firstString = firstString.substring(0, maxStringBytes); } byte[] valueBytes = StringUtils.toUtf8(firstString); mutationBuffer.putLong(position, time); mutationBuffer.putInt(position + Long.BYTES, valueBytes.length); mutationBuffer.position(position + Long.BYTES + Integer.BYTES); mutationBuffer.put(valueBytes); } }

Target:
public void aggregate(ByteBuffer buf, int position) { ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); Object value = valueSelector.getObject(); long time = timeSelector.getLong(); String firstString = null; if (value != null) { if (value instanceof SerializablePairLongString) { SerializablePairLongString serializablePair = (SerializablePairLongString) value; time = serializablePair.lhs; firstString = serializablePair.rhs; } else if (value instanceof String) { firstString = (String) value; } else { throw new ISE( "Try to aggregate unsuported class type [%s].Supported class types: String or SerializablePairLongString", value.getClass().getCanonicalName() ); } } long lastTime = mutationBuffer.getLong(position); if (time < lastTime) { if (firstString != null) { if (firstString.length() > maxStringBytes) { firstString = firstString.substring(0, maxStringBytes); } byte[] valueBytes = StringUtils.toUtf8(firstString); mutationBuffer.putLong(position, time); mutationBuffer.putInt(position + Long.BYTES, valueBytes.length); mutationBuffer.position(position + Long.BYTES + Integer.BYTES); mutationBuffer.put(valueBytes); } else { mutationBuffer.putLong(position, time); mutationBuffer.putInt(position + Long.BYTES, 0); } } }
Source:
public boolean isEnableForComponent(Component invoker) { contextId = -1; if (invoker instanceof JTree && SiteMapPanel.CONTEXT_TREE_COMPONENT_NAME.equals(invoker.getName())) { JTree contextTree = (JTree) invoker; if (!isEnabledForMultipleContexts()) { this.setEnabled(contextTree.getSelectionCount() < 2); } SiteNode node = (SiteNode) contextTree.getLastSelectedPathComponent(); if (node == null || node.isRoot()) { return false; } contextId = ((Target) node.getUserObject()).getContext().getId(); TreePath[] paths = contextTree.getSelectionPaths(); if (paths == null || paths.length == 0) return false; SiteNode[] nodes = Arrays.stream(paths) .map(p -> (SiteNode) p.getLastPathComponent()) .toArray(SiteNode[]::new); if (nodes.length == 1 && nodes[0].isRoot()) return false; Stream<Target> targets = Arrays.stream(nodes).map(n -> (Target) n.getUserObject()); contextIds.clear(); contextIds.addAll( Arrays.asList( targets.map(t -> t.getContext().getId()).toArray(Integer[]::new))); return isEnabledForContext(contextId); } return false; }

Target:
public boolean isEnableForComponent(Component invoker) { if (invoker instanceof JTree && SiteMapPanel.CONTEXT_TREE_COMPONENT_NAME.equals(invoker.getName())) { JTree contextTree = (JTree) invoker; if (!isEnabledForMultipleContexts()) { if (contextTree.getSelectionCount() < 2) { this.setEnabled(true); } else { this.setEnabled(false); return isEnabledForContext(getContextId()); } } SiteNode node = (SiteNode) contextTree.getLastSelectedPathComponent(); if (node == null || node.isRoot()) { return false; } contextIds.clear(); TreePath[] paths = contextTree.getSelectionPaths(); if (paths == null || paths.length == 0) return false; SiteNode[] nodes = Arrays.stream(paths) .map(p -> (SiteNode) p.getLastPathComponent()) .toArray(SiteNode[]::new); if (nodes.length == 1 && nodes[0].isRoot()) return false; Stream<Target> targets = Arrays.stream(nodes).map(n -> (Target) n.getUserObject()); contextIds.addAll( Arrays.asList( targets.map(t -> t.getContext().getId()).toArray(Integer[]::new))); return isEnabledForContext(getContextId()); } return false; }
Source:
public Map<AttributeSensor, Object> getAttributes() { if (attributesByKey == null) postDeserialize(); return fromPersistedMap(attributesByKey); }

Target:
public Map<AttributeSensor, Object> getAttributes() { if (attributesByKey == null) postDeserialize(); return Collections.unmodifiableMap(attributesByKey); }
Source:
public void update(float delta) { super.update(delta); int numSlots = getNumSlots(); if (numSlots < cells.size()) { for(int i = cells.size()-1; i >= 0; --i) { cells.remove(i); } } else if(numSlots > cells.size()) { for (int i = cells.size(); i < numSlots && i < getMaxCellCount(); ++i) { InventoryCell cell = new InventoryCell(); cell.bindTargetInventory(new ReadOnlyBinding<EntityRef>() { @Override public EntityRef get() { return getTargetEntity(); } }); cell.bindTargetSlot(new SlotBinding(i)); cells.add(cell); } } }

Target:
public void update(float delta) { super.update(delta); int numSlots = getNumSlots(); if (numSlots < cells.size()) { for (int i = cells.size(); i > numSlots && i > 0; --i) { cells.remove(i); } } else if (numSlots > cells.size()) { for (int i = cells.size(); i < numSlots && i < getMaxCellCount(); ++i) { InventoryCell cell = new InventoryCell(); cell.bindTargetInventory(new ReadOnlyBinding<EntityRef>() { @Override public EntityRef get() { return getTargetEntity(); } }); cell.bindTargetSlot(new SlotBinding(i)); cells.add(cell); } } }
Source:
public ITmfTrace getTrace() { ITmfProjectModelElement parent = getParent(); if (parent instanceof TmfExperimentElement) { ITmfTrace parentTrace = ((TmfExperimentElement) parent).getTrace(); if (parentTrace == null) { return null; } for (ITmfEventProvider sibling : parentTrace.getChildren()) { if (sibling instanceof ITmfTrace) { ITmfTrace siblingTrace = (ITmfTrace) sibling; if (getElementUnderTraceFolder().getResource().equals(siblingTrace.getResource())) { return siblingTrace; } } } return null; } return super.getTrace(); }

Target:
public ITmfTrace getTrace() { ITmfProjectModelElement parent = getParent(); if (parent instanceof TmfExperimentElement) { IResource resource = getElementUnderTraceFolder().getResource(); ITmfTrace experiment = ((TmfExperimentElement) parent).getTrace(); for (ITmfTrace trace : TmfTraceManager.getTraceSet(experiment)) { if (resource.equals(trace.getResource())) { return trace; } } return null; } return super.getTrace(); }