auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private static BlockPos getValidPos(World world, int x, int z, ITree tree){ if(Config.blacklistedTreeDims.contains(world.provider.getDimension())) return null; final BlockPos topPos = world.getHeight(new BlockPos(x, 0, z)); if (topPos.getY() == 0) { return null; } final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(topPos); IBlockState blockState = world.getBlockState(pos); IBlockState downState = world.getBlockState(pos.down()); while (BlockUtil.canReplace(blockState, world, pos)) { pos.move(EnumFacing.DOWN); if (pos.getY() <= 0) { return null; } blockState = world.getBlockState(pos); downState = world.getBlockState(pos.down()); } if(tree instanceof IPlantable && blockState.getBlock().canSustainPlant(blockState, world, pos, EnumFacing.UP, (IPlantable) tree)){ return pos.up(); } return null; }

Target:
private static BlockPos getValidPos(World world, int x, int z, ITree tree){ final BlockPos topPos = world.getHeight(new BlockPos(x, 0, z)); if (topPos.getY() == 0) { return null; } final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(topPos); IBlockState blockState = world.getBlockState(pos); IBlockState downState = world.getBlockState(pos.down()); while (BlockUtil.canReplace(blockState, world, pos)) { pos.move(EnumFacing.DOWN); if (pos.getY() <= 0) { return null; } blockState = world.getBlockState(pos); downState = world.getBlockState(pos.down()); } if(tree instanceof IPlantable && blockState.getBlock().canSustainPlant(blockState, world, pos, EnumFacing.UP, (IPlantable) tree)){ return pos.up(); } return null; }
Source:
private Set<String> getSourceIds(QueryRequest query) { Set<String> result; if (query.isEnterprise()) { result = Collections.singleton("enterprise"); } else if (query.getSourceIds() == null || query.getSourceIds().isEmpty()) { result = Collections.singleton(SystemInfo.getSiteName()); } else { result = query.getSourceIds(); } return result; }

Target:
private Set<String> getSourceIds(QueryRequest query) { if (query.isEnterprise()) { return Collections.singleton("enterprise"); } if (query.getSourceIds() == null || query.getSourceIds().isEmpty()) { return Collections.singleton(SystemInfo.getSiteName()); } return query.getSourceIds(); }
Source:
public int lookupId(@Nullable String name) { if (name == null) { return 0; } else { IdLookup idLookup = baseSelector.idLookup(); return (idLookup == null ? 0 : idLookup.lookupId(name)) + nullAdjustment; } }

Target:
public int lookupId(@Nullable String name) { if (name == null) { return 0; } else { IdLookup idLookup = baseSelector.idLookup(); assert idLookup != null; return idLookup.lookupId(name) + nullAdjustment; } }
Source:
private int getUpdatedCaretPosition(StringBuilder currentCalculatedMessage, int currentCaretPosition, CommitMessageWithCaretPosition messageWithPosition, ICommitMessageProvider2 provider) { int pos = currentCaretPosition; if (currentCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { String providedMessage = messageWithPosition.getMessage(); if (providedMessage == null || providedMessage.trim().isEmpty()) { return pos; } int providedCaretPosition = messageWithPosition .getDesiredCaretPosition(); if (providedCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { return pos; } if (providedCaretPosition > providedMessage.length() || providedCaretPosition < 0) { Activator.logWarning( MessageFormat.format( UIText.CommitDialog_CaretPositionOutOfBounds, provider.getClass().getName(), providedCaretPosition), null); return CommitMessageWithCaretPosition.NO_POSITION; } else { pos = currentCalculatedMessage.length(); if (currentCalculatedMessage.length() > 0) { pos += MESSAGE_SEPARATOR.length(); } pos += providedCaretPosition; } } else { Activator .logWarning( MessageFormat.format( UIText.CommitDialog_MultipleCommitMessageProvider2Implementations, provider.getClass().getName()), null); } return pos; }

Target:
private int getUpdatedCaretPosition(StringBuilder currentCalculatedMessage, int currentCaretPosition, CommitMessageWithCaretPosition messageWithPosition, ICommitMessageProvider2 provider) { int pos = currentCaretPosition; if (currentCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { String providedMessage = messageWithPosition.getMessage(); if (providedMessage == null || providedMessage.trim().isEmpty()) { return pos; } int providedCaretPosition = messageWithPosition .getDesiredCaretPosition(); if (providedCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { return pos; } if (providedCaretPosition > providedMessage.length() || providedCaretPosition < 0) { Activator.logWarning( MessageFormat.format( UIText.CommitDialog_CaretPositionOutOfBounds, provider.getClass().getName(), providedCaretPosition), null); return CommitMessageWithCaretPosition.NO_POSITION; } else { pos = currentCalculatedMessage.length(); if (currentCalculatedMessage.length() > 0) { pos += MESSAGE_SEPARATOR.length(); } pos += providedCaretPosition; } } else { Activator .logWarning( MessageFormat.format( UIText.CommitDialog_IgnoreCaretPosition, provider.getClass().getName()), null); } return pos; }
Source:
public void initialize( SchemaIndexDescriptor descriptor, IndexProgressor progressor, IndexQuery[] query ) { assert query != null && query.length > 0; super.initialize( progressor ); this.query = query; IndexQuery firstPredicate = query[0]; switch ( firstPredicate.type() ) { case exact: seekQuery( descriptor, query ); break; case exists: scanQuery( descriptor ); break; case range: assert query.length == 1; rangeQuery( descriptor, (IndexQuery.RangePredicate) firstPredicate ); break; case stringPrefix: prefixQuery( descriptor, (IndexQuery.StringPrefixPredicate) firstPredicate ); break; case stringSuffix: case stringContains: assert query.length == 1; suffixOrContainsQuery( descriptor, firstPredicate ); break; default: throw new UnsupportedOperationException( "Query not supported: " + Arrays.toString( query ) ); } }

Target:
public void initialize( SchemaIndexDescriptor descriptor, IndexProgressor progressor, IndexQuery[] query ) { assert query != null && query.length > 0; super.initialize( progressor ); this.query = query; IndexQuery firstPredicate = query[0]; switch ( firstPredicate.type() ) { case exact: seekQuery( descriptor, query ); break; case exists: scanQuery( descriptor ); break; case range: assert query.length == 1; rangeQuery( descriptor, (IndexQuery.RangePredicate) firstPredicate ); break; case stringPrefix: assert query.length == 1; prefixQuery( descriptor, (IndexQuery.StringPrefixPredicate) firstPredicate ); break; case stringSuffix: case stringContains: assert query.length == 1; suffixOrContainsQuery( descriptor, firstPredicate ); break; default: throw new UnsupportedOperationException( "Query not supported: " + Arrays.toString( query ) ); } }
Source:
public static Set<URI> parseAllowedCorsOrigins(String allowedCorsOrigins) throws Exception { String[] stringOrigins = allowedCorsOrigins.split(","); Set<URI> parsedOrigins = new HashSet<>(); for (String origin : stringOrigins) { parsedOrigins.add(new URI(origin)); } return parsedOrigins; }

Target:
public static Set<URI> parseAllowedCorsOrigins(String allowedCorsOrigins) throws URISyntaxException { String[] stringOrigins = allowedCorsOrigins.split(","); Set<URI> parsedOrigins = new HashSet<>(); for (String origin : stringOrigins) { parsedOrigins.add(new URI(origin.trim())); } return parsedOrigins; }
Source:
public static String countryCodeToEmoji(String countryCode) { int char1 = Character.codePointAt(countryCode, 0) - 0x41 + 0x1F1E6; int char2 = Character.codePointAt(countryCode, 1) - 0x41 + 0x1F1E6; return new String(Character.toChars(char1)) + new String(Character.toChars(char2)); }

Target:
public static String countryCodeToEmoji(String countryCode) { if (TextUtils.isEmpty(countryCode) || countryCode.length() != 2) { return ""; } int char1 = Character.codePointAt(countryCode, 0) - 0x41 + 0x1F1E6; int char2 = Character.codePointAt(countryCode, 1) - 0x41 + 0x1F1E6; return new String(Character.toChars(char1)) + new String(Character.toChars(char2)); }
Source:
public void perform(Object... args) { if (args.length == 0) { controller.action(ChooseFile.class, true, this); } else { fileChosen(args[0].toString(), null); } }

Target:
public void perform(Object... args) { if (args.length == 0) { controller.action(ChooseFile.class, true, this); } else { fileChosen(args[0].toString(), Result.SUCCESS); } }
Source:
public EventType findByName(final String name) throws NoSuchEventTypeException { final String sql = "SELECT et_topic, et_event_type_object, et_deleted " + "FROM zn_data.event_type WHERE et_name = ?"; try { final EventType eventType = jdbcTemplate.queryForObject(sql, new Object[]{name}, new EventTypeMapper()); if (eventType.isDeleted()) { throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist."); } return eventType; } catch (EmptyResultDataAccessException e) { throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist.", e); } }

Target:
public EventType findByName(final String name) throws NoSuchEventTypeException { final String sql = "SELECT et_topic, et_event_type_object, et_archived " + "FROM zn_data.event_type WHERE et_name = ? AND et_archived = FALSE"; try { return jdbcTemplate.queryForObject(sql, new Object[]{name}, new EventTypeMapper()); } catch (EmptyResultDataAccessException e) { throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist.", e); } }
Source:
private static IdentifierTree getIdentifier(ExpressionTree tree) { if (isIdentifier(tree)) { return (IdentifierTree) tree; } return null; }

Target:
private static Symbol getIdentifier(ExpressionTree tree) { if (tree.is(Kind.IDENTIFIER)) { return ((IdentifierTree) tree).symbol(); } return null; }
Source:
private View getSectionDividerView(View convertView, ViewGroup parent) { Activity context = activity.get(); if(context == null) { return null; } LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (UserPreferences.getFeedFilter() != UserPreferences.FEED_FILTER_NONE) { convertView = inflater.inflate(R.layout.nav_section_filter_divider, parent, false); convertView.setEnabled(true); convertView.setOnClickListener((l) -> FeedFilterDialog.showDialog(context)); } else { convertView = inflater.inflate(R.layout.nav_section_item, parent, false); convertView.setEnabled(false); convertView.setOnClickListener(null); } return convertView; }

Target:
private View getSectionDividerView(View convertView, ViewGroup parent) { Activity context = activity.get(); if(context == null) { return null; } LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.nav_section_item, parent, false); TextView feedsFilteredMsg = convertView.findViewById(R.id.nav_feeds_filtered_message); if (UserPreferences.getFeedFilter() != UserPreferences.FEED_FILTER_NONE && showSubscriptionList) { convertView.setEnabled(true); feedsFilteredMsg.setText("{md-info-outline} " + context.getString(R.string.subscriptions_are_filtered)); Iconify.addIcons(feedsFilteredMsg); feedsFilteredMsg.setVisibility(View.VISIBLE); } else { convertView.setEnabled(false); feedsFilteredMsg.setVisibility(View.GONE); } return convertView; }
Source:
protected void render0(FunctionRenderContext context) { context.addArgument(0); context.addChunk("::json"); context.addChunk("#>>'{"); addUnquotedArgument(context, 1); for (int i = 2; i < context.getArgumentsSize(); i++) { context.addChunk(","); addUnquotedArgument(context, i); } context.addChunk("}'"); }

Target:
protected void render0(FunctionRenderContext context) { context.addChunk("cast("); context.addArgument(0); context.addChunk(" as json)"); context.addChunk("#>>'{"); addUnquotedArgument(context, 1); for (int i = 2; i < context.getArgumentsSize(); i++) { context.addChunk(","); addUnquotedArgument(context, i); } context.addChunk("}'"); }
Source:
public JSONObject changeLibraryIdBarcode(HttpSession session, JSONObject json) { Long libraryId = json.getLong("libraryId"); String idBarcode = json.getString("identificationBarcode"); try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); if (!isStringEmptyOrNull(idBarcode)) { Collection<Boxable> previouslyBarcodedItems = requestManager.getBoxablesFromBarcodeList(Arrays.asList(new String[] { idBarcode })); if (!previouslyBarcodedItems.isEmpty()) { Boxable previouslyBarcodedItem = previouslyBarcodedItems.iterator().next(); String error = String.format( "Could not change library identification barcode to '%s'. This barcode is already in use by an item with the name '%s' and the alias '%s'.", idBarcode, previouslyBarcodedItem.getName(), previouslyBarcodedItem.getAlias()); log.debug(error); return JSONUtils.SimpleJSONError(error); } Library library = requestManager.getLibraryById(libraryId); library.setIdentificationBarcode(idBarcode); library.setLastModifier(user); requestManager.saveLibrary(library); } else { return JSONUtils.SimpleJSONError("New identification barcode not recognized"); } } catch (IOException e) { log.debug("Could not change Library identificationBarcode: " + e.getMessage()); return JSONUtils.SimpleJSONError(e.getMessage()); } return JSONUtils.SimpleJSONResponse("New identification barcode successfully assigned."); }

Target:
public JSONObject changeLibraryIdBarcode(HttpSession session, JSONObject json) { Long libraryId = json.getLong("libraryId"); String idBarcode = json.getString("identificationBarcode"); try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); if (!isStringEmptyOrNull(idBarcode)) { List<Boxable> previouslyBarcodedItems = new ArrayList<Boxable>(requestManager.getBoxablesFromBarcodeList(Arrays.asList(idBarcode))); if (!previouslyBarcodedItems.isEmpty() && !(previouslyBarcodedItems.size() == 1 && previouslyBarcodedItems.get(0).getId() == libraryId)) { Boxable previouslyBarcodedItem = previouslyBarcodedItems.get(0); String error = String.format( "Could not change library identification barcode to '%s'. This barcode is already in use by an item with the name '%s' and the alias '%s'.", idBarcode, previouslyBarcodedItem.getName(), previouslyBarcodedItem.getAlias()); log.debug(error); return JSONUtils.SimpleJSONError(error); } Library library = requestManager.getLibraryById(libraryId); library.setIdentificationBarcode(idBarcode); library.setLastModifier(user); requestManager.saveLibrary(library); } else { return JSONUtils.SimpleJSONError("New identification barcode not recognized"); } } catch (IOException e) { log.debug("Could not change Library identificationBarcode: " + e.getMessage()); return JSONUtils.SimpleJSONError(e.getMessage()); } return JSONUtils.SimpleJSONResponse("New identification barcode successfully assigned."); }
Source:
public static String format(Date date, boolean init) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.'000Z'"); if (!init) sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'"); sdf.setTimeZone(TimeZone.getTimeZone("ZULU")); String ret = sdf.format(date); return ret; }

Target:
public static String format(Date date, boolean init) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.'000Z'"); if (!init) { sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'"); } sdf.setTimeZone(TimeZone.getTimeZone("ZULU")); String ret = sdf.format(date); return ret; }
Source:
public V get(Object key) { assertKeyNotNull(key); checkCanRun(cache, componentRegistry); InternalCacheEntry<K, V> ice = getDataContainer().get(key); if (ice != null) { return ice.getValue(); } return null; }

Target:
public V get(Object key) { assertKeyNotNull(key); checkCanRun(cache, cache.getName()); InternalCacheEntry<K, V> ice = getDataContainer().get(key); if (ice != null) { return ice.getValue(); } return null; }
Source:
public String getLineContent(Repository repository, int lineNumber) throws IOException { Line line = getLine(lineNumber); if (line == null) return null; ObjectLoader loader = repository.open(blob, Constants.OBJ_BLOB); byte[] contents; if (loader.isLarge()) contents = IO.readWholeStream(loader.openStream(), (int) loader.getSize()).array(); else contents = loader.getCachedBytes(); return new RawText(contents).getString(lineNumber); }

Target:
public String getLineContent(Repository repository, int lineNumber) throws IOException { return getLineContent(repository, lineNumber, Constants.CHARSET); }
Source:
private static Map<String, String> buildParamsMap(String params) { if (params.startsWith("/")) { params = params.substring(1); } String[] pathParts = params.split("/"); Map<String, String> pathMap = new HashMap<String, String>(); for (int i=0; i < pathParts.length/2; i++) { String key = pathParts[2*i].toLowerCase(); String value = pathParts[2*i+1]; if (!value.toLowerCase().equals("null")) { pathMap.put(key, value); } } return pathMap; }

Target:
private static Map<String, String> buildParamsMap(String params) { if (params.startsWith("/")) { params = params.substring(1); } String[] pathParts = params.split("/"); Map<String, String> pathMap = new HashMap<String, String>(); for (int i=0; i < pathParts.length/2; i++) { String key = pathParts[2*i].toLowerCase(); String value = pathParts[2*i+1]; if (UtilMethods.isSet(value)) { pathMap.put(key, value); } } return pathMap; }
Source:
public static void exit() { SaveGameWriter.saveGame("firstActualGame.json"); stage.close(); }

Target:
public static void exit() { createSaveDirectory(); SaveGameWriter.saveGame("sav/save.json"); stage.close(); }
Source:
public <T> Serializer<T> createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?>... configs) throws UnsupportedTypeException { Serializer<T> serializer = (Serializer<T>) getUserProvidedSerializer(find(DefaultSerializerConfiguration.Type.KEY, configs)); if (serializer == null) { DefaultSerializerConfiguration<T> conf = find(DefaultSerializerConfiguration.Type.KEY, configs); serializer = createSerializer(clazz, classLoader, conf, configs); instantiated.add(serializer); } updateProvidedInstanceCounts(serializer); return serializer; }

Target:
public <T> Serializer<T> createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?>... configs) throws UnsupportedTypeException { DefaultSerializerConfiguration<T> configuration = find(DefaultSerializerConfiguration.Type.KEY, configs); Serializer<T> serializer = getUserProvidedSerializer(configuration); if (serializer == null) { serializer = createSerializer(clazz, classLoader, configuration, configs); instantiated.add(serializer); } updateProvidedInstanceCounts(serializer); return serializer; }
Source:
public void category_001_openNavigate() { init(); category.toggle(); category.openLink(0); }

Target:
public void category_001_openNavigate() { init(); category.toggle(); category.openCategoryPage(0); }
Source:
public ScriptEventsIterator getEventIterator(@Nullable ITmfTrace trace) { if (trace == null) { throw new NullPointerException("Trace should not be null"); } ScriptEventRequest scriptEventRequest = new ScriptEventRequest(); trace.sendRequest(scriptEventRequest); getScriptEngine().addExecutionListener(new IExecutionListener() { @Override public void notify(@Nullable IScriptEngine engine, @Nullable Script script, int status) { if (status == SCRIPT_END) { scriptEventRequest.done(); } } }); return scriptEventRequest.getEventIterator(); }

Target:
public ScriptEventsIterator getEventIterator(@Nullable ITmfTrace trace) { if (trace == null) { throw new NullPointerException("Trace should not be null"); } ScriptEventRequest scriptEventRequest = new ScriptEventRequest(); trace.sendRequest(scriptEventRequest); setupEventIteratorExecutionListener(scriptEventRequest); return scriptEventRequest.getEventIterator(); }
Source:
private void changeRegion(RateControlRegion region, long nowMs) { if (rateControlRegion == region) { return; } rateControlRegion = region; if (logger.isTraceEnabled()) { logger.trace(Logger.Category.BWE, diagnosticContext .makeTimeSeriesPoint("aimd_region", nowMs) .addKey("aimd", hashCode()) .addField("value", region).toString()); } }

Target:
private void changeRegion(RateControlRegion region, long nowMs) { if (rateControlRegion == region) { return; } rateControlRegion = region; if (logger.isTraceEnabled()) { logger.trace(Logger.Category.BWE, diagnosticContext .makeTimeSeriesPoint("aimd_region", nowMs) .addKey("aimd", hashCode()) .addField("value", region)); } }
Source:
public List<String> listAndVerifyDetectors(String host, InetSocketAddress sshAddr) throws Exception { try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) { PrintStream pipe = sshClient.openShell(); pipe.println("provision:list-detectors"); pipe.println("logout"); await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable()); String shellOutput = sshClient.getStdout(); shellOutput = StringUtils.substringAfter(shellOutput, "provision:list-detectors"); LOG.info("Detectors output: {}", shellOutput); Map<String, String> detectorMap = new HashMap<String, String>(); for (String detector : shellOutput.split("\\r?\\n")) { if (StringUtils.isNotBlank(detector)) { String detectorSet[] = detector.split(":"); if (detectorSet.length >= 2) { detectorMap.put(detectorSet[0], detectorSet[1]); } } } LOG.info("Found detectors: {}", detectorMap); return expectedDetectors.keySet().stream().filter(e -> { return detectorMap.keySet().stream().noneMatch(s -> s.contains(e)); }).collect(Collectors.toList()); } }

Target:
public List<String> listAndVerifyDetectors(String host, InetSocketAddress sshAddr) throws Exception { List<String> unmatchedDetectors = new ArrayList<>(); try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) { PrintStream pipe = sshClient.openShell(); pipe.println("provision:list-detectors"); pipe.println("logout"); await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable()); String shellOutput = CommandTestUtils.stripAnsiCodes(sshClient.getStdout()); shellOutput = StringUtils.substringAfter(shellOutput, "provision:list-detectors"); LOG.info("Detectors output: {}", shellOutput); Map<String, String> detectorMap = new HashMap<String, String>(); for (String detector : shellOutput.split("\\r?\\n")) { if (StringUtils.isNotBlank(detector)) { String detectorSet[] = detector.split(":"); if (detectorSet.length >= 2) { detectorMap.put(detectorSet[0], detectorSet[1]); } } } LOG.info("Found detectors: {}", detectorMap); for (String detectorName : expectedDetectors.keySet()) { if (!detectorMap.containsKey(detectorName)) { unmatchedDetectors.add(detectorName); } } } return unmatchedDetectors; }
Source:
public ClientDriverRequest(HttpServletRequest request) { this.path = request.getPathInfo(); this.method = Enum.valueOf(Method.class, request.getMethod()); this.params = HashMultimap.create(); String queryString = request.getQueryString(); if (StringUtils.isNotEmpty(StringUtils.trimToEmpty(queryString))) { String[] splitQueryString = queryString.split("&"); for (int i = 0; i < splitQueryString.length; i++) { String[] queryPair = splitQueryString[i].split("="); this.params.put(queryPair[0], queryPair[1]); } } headers = new HashMap<String, Object>(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); headers.put(headerName, request.getHeader(headerName)); } } try { this.bodyContent = IOUtils.toString(request.getReader()); } catch (IOException e) { throw new RuntimeException("Failed to read body of request", e); } this.bodyContentType = request.getContentType(); }

Target:
public ClientDriverRequest(HttpServletRequest request) { this.path = request.getPathInfo(); this.method = Enum.valueOf(Method.class, request.getMethod()); this.params = HashMultimap.create(); Map<String, String[]> parameterMap = request.getParameterMap(); for (Entry<String, String[]> paramEntry : parameterMap.entrySet()) { String[] values = paramEntry.getValue(); for (String value : values) { this.params.put(paramEntry.getKey(), value); } } headers = new HashMap<String, Object>(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); headers.put(headerName, request.getHeader(headerName)); } } try { this.bodyContent = IOUtils.toString(request.getReader()); } catch (IOException e) { throw new RuntimeException("Failed to read body of request", e); } this.bodyContentType = request.getContentType(); }
Source:
void setPictureSize(Size size) { if (size == null) { if (mAspectRatio == null) { return; } SortedSet<Size> sizes = mPictureSizes.sizes(mAspectRatio); if(sizes != null && !sizes.isEmpty()) { mPictureSize = sizes.last(); } } else { mPictureSize = size; } if (mCameraParameters != null && mCamera != null) { mCameraParameters.setPictureSize(mPictureSize.getWidth(), mPictureSize.getHeight()); try{ mCamera.setParameters(mCameraParameters); } catch(RuntimeException e ) { Log.e("Camera1", "setParameters failed", e); } } }

Target:
void setPictureSize(Size size) { if (size == null) { if (mAspectRatio == null) { return; } SortedSet<Size> sizes = mPictureSizes.sizes(mAspectRatio); if(sizes != null && !sizes.isEmpty()) { mPictureSize = sizes.last(); } } else { mPictureSize = size; } if (mCameraParameters != null && mCamera != null) { mCameraParameters.setPictureSize(mPictureSize.getWidth(), mPictureSize.getHeight()); try{ mCamera.setParameters(mCameraParameters); } catch(RuntimeException e ) { Log.e("CAMERA_1::", "setParameters failed", e); } } }
Source:
protected String cleanStringValue( Class<? extends PersistableBusinessObject> businessObjectClass, String propertyName, String propertyValue) { String cleanedValue = StringUtils.defaultIfBlank(propertyValue, null); Integer maxLength = dataDictionaryService.getAttributeMaxLength(businessObjectClass, propertyName); if (maxLength != null && maxLength > 0 && StringUtils.length(cleanedValue) > maxLength) { LOG.info("cleanStringValue, Truncating value for business object " + businessObjectClass.getName() + " and property " + propertyName); cleanedValue = StringUtils.left(cleanedValue, maxLength); } return cleanedValue; }

Target:
protected String cleanStringValue( Class<? extends PersistableBusinessObject> businessObjectClass, String propertyName, String propertyValue) { String cleanedValue = StringUtils.defaultIfBlank(propertyValue, null); if (ObjectUtils.isNotNull(cleanedValue)) { cleanedValue = cleanedValue.trim(); } Integer maxLength = dataDictionaryService.getAttributeMaxLength(businessObjectClass, propertyName); if (maxLength != null && maxLength > 0 && StringUtils.length(cleanedValue) > maxLength) { LOG.info("cleanStringValue, Truncating value for business object " + businessObjectClass.getName() + " and property " + propertyName); cleanedValue = StringUtils.left(cleanedValue, maxLength); } return cleanedValue; }
Source:
public void setUpExecutor() throws Exception { sqlExecutor = SQLExecutor.builder(clusterService) .addTable("CREATE TABLE t (" + " id int," + " qty int," + " sentinel boolean CONSTRAINT sentinel CHECK(sentinel)," + " CONSTRAINT id_is_even CHECK(id % 2 = 0))") .build(); docTableInfo = sqlExecutor.resolveTableInfo("t"); txnCtx = CoordinatorTxnCtx.systemTransactionContext(); checkConstraints = new CheckConstraints( txnCtx, new InputFactory(sqlExecutor.functions()), FromSourceRefResolver.WITHOUT_PARTITIONED_BY_REFS, docTableInfo); }

Target:
public void setUpExecutor() throws Exception { SQLExecutor sqlExecutor = SQLExecutor.builder(clusterService) .addTable("CREATE TABLE t (" + " id int," + " qty int," + " sentinel boolean CONSTRAINT sentinel CHECK(sentinel)," + " CONSTRAINT id_is_even CHECK(id % 2 = 0))") .build(); DocTableInfo docTableInfo = sqlExecutor.resolveTableInfo("t"); TransactionContext txnCtx = CoordinatorTxnCtx.systemTransactionContext(); checkConstraints = new CheckConstraints( txnCtx, new InputFactory(sqlExecutor.functions()), FromSourceRefResolver.WITHOUT_PARTITIONED_BY_REFS, docTableInfo); }
Source:
public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) doPop(e); }

Target:
public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { doPop(e); } }
Source:
public String generatePageActionLogMessage(String url, Map<String, String[]> params, UserType currUser, AccountAttributes userAccount, StudentAttributes unregisteredStudent, String logMessage) { Builder builder = generateBasicActivityLogEntry(url, params, currUser); boolean isUnregisteredStudent = unregisteredStudent != null; boolean isAccountWithGoogleId = userAccount != null && userAccount.googleId != null; if (isUnregisteredStudent) { updateInfoForUnregisteredStudent(builder, unregisteredStudent); } else if (isAccountWithGoogleId) { updateInfoForNormalUser(builder, currUser, userAccount); } builder.withLogMessage(logMessage); return builder.build().generateLogMessage(); }

Target:
public String generatePageActionLogMessage(String url, Map<String, String[]> params, UserType currUser, AccountAttributes userAccount, StudentAttributes unregisteredStudent, String logMessage) { Builder builder = generateBasicLogEntryBuilder(url, params, currUser); boolean isUnregisteredStudent = unregisteredStudent != null; boolean isAccountWithGoogleId = userAccount != null && userAccount.googleId != null; if (isUnregisteredStudent) { updateInfoForUnregisteredStudent(builder, unregisteredStudent); } else if (isAccountWithGoogleId) { updateInfoForNormalUser(builder, currUser, userAccount); } builder.withLogMessage(logMessage); return builder.build().generateLogMessage(); }
Source:
boolean connect() throws IOException { if (isConnected) { return true; } try { socket = new Socket(inetAddress, port); if (socket.isConnected()) { isConnected = true; return true; } } catch (Exception e) { logger.error("Bind Exception Already Connected ", e); } return false; }

Target:
boolean connect() throws IOException { if (isConnected) { return true; } socket = new Socket(inetAddress, port); if (socket.isConnected()) { isConnected = true; return true; } return false; }
Source:
@Test public void testWriter() { String s = Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> { rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema())); LogicalTableScan scan = LogicalTableScan.create(cluster, relOptSchema.getTableForMember( asList("hr", "emps")), ImmutableList.of()); final RexBuilder rexBuilder = cluster.getRexBuilder(); LogicalFilter filter = LogicalFilter.create(scan, rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, rexBuilder.makeFieldAccess( rexBuilder.makeRangeReference(scan), "deptno", true), rexBuilder.makeExactLiteral(BigDecimal.TEN))); final RelJsonWriter writer = new RelJsonWriter(); final RelDataType bigIntType = cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT); LogicalAggregate aggregate = LogicalAggregate.create(filter, ImmutableList.of(), ImmutableBitSet.of(0), null, ImmutableList.of( AggregateCall.create(SqlStdOperatorTable.COUNT, true, false, false, ImmutableList.of(1), -1, RelCollations.EMPTY, bigIntType, "c"), AggregateCall.create(SqlStdOperatorTable.COUNT, false, false, false, ImmutableList.of(), -1, RelCollations.EMPTY, bigIntType, "d"))); aggregate.explain(writer); return writer.asString(); }); assertThat(s, is(XX)); }

Target:
@Test public void testWriter() { String s = Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> { rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema())); LogicalTableScan scan = LogicalTableScan.create(cluster, relOptSchema.getTableForMember( Arrays.asList("hr", "emps")), ImmutableList.of()); final RexBuilder rexBuilder = cluster.getRexBuilder(); LogicalFilter filter = LogicalFilter.create(scan, rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, rexBuilder.makeFieldAccess( rexBuilder.makeRangeReference(scan), "deptno", true), rexBuilder.makeExactLiteral(BigDecimal.TEN))); final RelJsonWriter writer = new RelJsonWriter(); final RelDataType bigIntType = cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT); LogicalAggregate aggregate = LogicalAggregate.create(filter, ImmutableList.of(), ImmutableBitSet.of(0), null, ImmutableList.of( AggregateCall.create(SqlStdOperatorTable.COUNT, true, false, false, ImmutableList.of(1), -1, RelCollations.EMPTY, bigIntType, "c"), AggregateCall.create(SqlStdOperatorTable.COUNT, false, false, false, ImmutableList.of(), -1, RelCollations.EMPTY, bigIntType, "d"))); aggregate.explain(writer); return writer.asString(); }); assertThat(s, is(XX)); }
Source:
public static void input( @AggregationState DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double percentile) { initializeDigest(state); QuantileDigest digest = state.getDigest(); state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes()); digest.add(value); state.addMemoryUsage(digest.estimatedInMemorySizeInBytes()); state.setPercentile(percentile); }

Target:
public static void input( @AggregationState DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double percentile) { addInput(state, value, DEFAULT_WEIGHT, percentile, DEFAULT_ACCURACY); }
Source:
private MessageDigest initCopyPack(PackOutputStream out, boolean validate, DfsReader ctx) throws IOException { if (length == -1) ctx.pin(this, 0); if (!validate) { ctx.unpin(); return null; } int hdrlen = 12; byte[] buf = out.getCopyBuffer(); int n = ctx.copy(this, 0, buf, 0, hdrlen); ctx.unpin(); if (n != hdrlen) { setInvalid(); throw new IOException(MessageFormat.format( JGitText.get().packfileIsTruncated, getPackName())); } MessageDigest md = Constants.newMessageDigest(); md.update(buf, 0, hdrlen); return md; }

Target:
private MessageDigest initCopyPack(PackOutputStream out, boolean validate, DfsReader ctx) throws IOException { if (length == -1) ctx.pin(this, 0); if (!validate) { ctx.unpin(); return null; } int hdrlen = 12; byte[] buf = out.getCopyBuffer(); int n = ctx.copy(this, 0, buf, 0, hdrlen); ctx.unpin(); if (n != hdrlen) throw packfileIsTruncated(); MessageDigest md = Constants.newMessageDigest(); md.update(buf, 0, hdrlen); return md; }
Source:
public boolean valueContains(String value) { if (this.getType().equals(String.class.getName()) || this.getType().equals("java.lang.LargeString")) { return value == null ? this.getValue() == null : value.equals(this.getValue()); } else if (this.getType().equals(ArrayList.class.getName()) || this.getType().equals("java.util.LargeArrayList")) { return this.getValue() == null ? value == null : ((ArrayList<String>) this.getValue()).contains(value); } else if (this.getType().equals(LinkedHashMap.class.getName())) { return this.getValue() == null ? value == null : (((LinkedHashMap<String, String>) this.getValue()).containsKey(value) || ((LinkedHashMap<String, String>) this.getValue()).containsValue(value)); } else return false; }

Target:
public boolean valueContains(String value) { if (this.getType().equals(String.class.getName()) || this.getType().equals(BeansUtils.largeStringClassName)) { return value == null ? this.getValue() == null : value.equals(this.getValue()); } else if (this.getType().equals(ArrayList.class.getName()) || this.getType().equals(BeansUtils.largeArrayListClassName)) { return this.getValue() == null ? value == null : ((ArrayList<String>) this.getValue()).contains(value); } else if (this.getType().equals(LinkedHashMap.class.getName())) { return this.getValue() == null ? value == null : (((LinkedHashMap<String, String>) this.getValue()).containsKey(value) || ((LinkedHashMap<String, String>) this.getValue()).containsValue(value)); } else return false; }
Source:
public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); Bundle data = getArguments(); final Uri dataUri = data.getParcelable("ARG_DATA_URI"); AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()) .setIcon(android.R.drawable.ic_dialog_info) .setTitle("Upload key") .setMessage("Do you want to upload your key to the server?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ((EditKeyActivity) getActivity()).uploadToKeyserver(dataUri); } }) .setNegativeButton("No", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { ((EditKeyActivity) getActivity()).finish(); } }); return dialog.create(); }

Target:
public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); Bundle data = getArguments(); final Uri dataUri = data.getParcelable(EditKeyActivity.ARG_DATA_URI); AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()) .setIcon(android.R.drawable.ic_dialog_info) .setTitle(getString(R.string.section_upload_key)) .setMessage(getString(R.string.upload_key_dialog_message)) .setPositiveButton(getString(R.string.choice_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ((EditKeyActivity) getActivity()).uploadToKeyserver(dataUri); } }) .setNegativeButton(getString(R.string.choice_no), new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { ((EditKeyActivity) getActivity()).finish(); } }); return dialog.create(); }
Source:
private void outputTangentNormalizationResult(final TangentNormalizationResult tangentNormalizationResult){ writeTangentNormalizedOutput(tangentNormalizationResult.getTangentNormalized()); writePreTangentNormalizationOutput(tangentNormalizationResult.getPreTangentNormalized()); writeTangentBetaHats(tangentNormalizationResult.getTangentBetaHats(), tangentNormalizationResult.getTargetFactorNormalizedCounts().columnNames()); writeTargetFactorNormalizedOutput(tangentNormalizationResult.getTargetFactorNormalizedCounts()); }

Target:
private void outputTangentNormalizationResult(final TangentNormalizationResult tangentNormalizationResult){ writeTargetFactorNormalizedOutput(tangentNormalizationResult.getTargetFactorNormalizedCounts()); writePreTangentNormalizationOutput(tangentNormalizationResult.getPreTangentNormalized()); writeTangentBetaHats(tangentNormalizationResult.getTangentBetaHats(), tangentNormalizationResult.getTargetFactorNormalizedCounts().columnNames()); writeTangentNormalizedOutput(tangentNormalizationResult.getTangentNormalized()); }
Source:
public static boolean checkValidity(final byte[] keystore, final char[] password) { try { final KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE); keyStore.load(new ByteArrayInputStream(keystore), password); final Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { final String alias = aliases.nextElement(); final X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias); try{ certificate.checkValidity(); } catch (CertificateExpiredException | CertificateNotYetValidException e) { LOGGER.error("Provided APNs .p12 file is not valid"); return false; } } } catch (Exception e) { LOGGER.error("Error parsing .p12 file content", e); return false; } return true; }

Target:
public static boolean checkValidity(final byte[] keystore, final char[] password) { try { final KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE); keyStore.load(new ByteArrayInputStream(keystore), password); final Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { final String alias = aliases.nextElement(); final X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias); final X500Principal subjectX500Principal = certificate.getSubjectX500Principal(); final String subject = subjectX500Principal.getName(); final Matcher matcher = COMMON_NAME_PATTERN.matcher(subject); while(matcher.find()) { if (PUSH_SUBJECTS.contains(matcher.group(1))) { try{ certificate.checkValidity(); break; } catch (CertificateExpiredException | CertificateNotYetValidException e) { LOGGER.error("Provided APNs .p12 file is expired or not yet valid"); return false; } } } } return true; } catch (Exception e) { LOGGER.error("Error parsing .p12 file content", e); return false; } }
Source:
private static List<Symbol> cast(List<Symbol> symbolsToCast, List<DataType> targetTypes) { Preconditions.checkState(symbolsToCast.size() == targetTypes.size(), "Given symbol list has to match the target type list."); int size = symbolsToCast.size(); List<Symbol> castList = new ArrayList<>(size); for (int i = 0; i < size; i++) { var symbolToCast = symbolsToCast.get(i); if (ArrayType.unnest(symbolToCast.valueType()).id() != ObjectType.ID) { symbolToCast = symbolToCast.cast(targetTypes.get(i), false); } castList.add(symbolToCast); } return castList; }

Target:
private static List<Symbol> cast(List<Symbol> symbolsToCast, List<DataType> targetTypes) { Preconditions.checkState(symbolsToCast.size() == targetTypes.size(), "Given symbol list has to match the target type list."); int size = symbolsToCast.size(); List<Symbol> castList = new ArrayList<>(size); for (int i = 0; i < size; i++) { var symbolToCast = symbolsToCast.get(i); var targetType = targetTypes.get(i); if (targetType.id() == UndefinedType.ID) { castList.add(symbolToCast); } else { castList.add(symbolToCast.cast(targetType, false)); } } return castList; }
Source:
private void setupNetworkDao() { when(getDbFacadeMockInstance().getNetworkDao()).thenReturn(networkDaoMock); when(networkDaoMock.get(networkId)).thenReturn((networkMocked)); when(networkMocked.getQosId()).thenReturn(null); }

Target:
private void setupNetworkDao() { when(getDbFacadeMockInstance().getNetworkDao()).thenReturn(networkDaoMock); when(networkDaoMock.get(networkId)).thenReturn((networkMocked)); }
Source:
public Object resource() { KeycloakIdentity identity = createIdentity(true); ResourceServer resourceServer = getResourceServer(identity); RealmModel realm = authorization.getRealm(); ClientModel client = realm.getClientByClientId(identity.getAccessToken().getIssuedFor()); KeycloakSession keycloakSession = authorization.getKeycloakSession(); UserModel serviceAccount = keycloakSession.users().getServiceAccount(client); AdminEventBuilder adminEvent = new AdminEventBuilder(realm, new AdminAuth(realm, identity.getAccessToken(), serviceAccount, client), keycloakSession, clientConnection); ResourceSetService resourceManager = new ResourceSetService(resourceServer, this.authorization, null, adminEvent.realm(realm).authClient(client).authUser(serviceAccount)); ResteasyProviderFactory.getInstance().injectProperties(resourceManager); ResourceService resource = new ResourceService(resourceServer, identity, resourceManager); ResteasyProviderFactory.getInstance().injectProperties(resource); return resource; }

Target:
public Object resource() { KeycloakIdentity identity = createIdentity(true); ResourceServer resourceServer = getResourceServer(identity); RealmModel realm = authorization.getRealm(); ClientModel client = realm.getClientById(resourceServer.getId()); KeycloakSession keycloakSession = authorization.getKeycloakSession(); UserModel serviceAccount = keycloakSession.users().getServiceAccount(client); AdminEventBuilder adminEvent = new AdminEventBuilder(realm, new AdminAuth(realm, identity.getAccessToken(), serviceAccount, client), keycloakSession, clientConnection); ResourceSetService resourceManager = new ResourceSetService(resourceServer, this.authorization, null, adminEvent.realm(realm).authClient(client).authUser(serviceAccount)); ResteasyProviderFactory.getInstance().injectProperties(resourceManager); ResourceService resource = new ResourceService(resourceServer, identity, resourceManager); ResteasyProviderFactory.getInstance().injectProperties(resource); return resource; }
Source:
public boolean validate(final JEEContext context) { val clientId = OAuth20Utils.getClientIdAndClientSecret(context).getLeft(); val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId); if (registeredService == null) { LOGGER.warn("Provided client id cannot be matched against a service definition"); return false; } return true; }

Target:
public boolean validate(final JEEContext context) { val clientId = OAuth20Utils.getClientIdAndClientSecret(context).getLeft(); val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId); if (registeredService == null) { LOGGER.warn("Provided client id cannot be matched against a service definition", clientId); return false; } return true; }
Source:
private void addOverride(JsonNode root, String name, String value) { JsonNode node = root; final Iterator<String> keys = Splitter.on('.').trimResults().split(name).iterator(); while (keys.hasNext()) { final String key = keys.next(); if (!(node instanceof ObjectNode)) { throw new IllegalArgumentException("Unable to override " + name + "; it's not a valid path."); } final ObjectNode obj = (ObjectNode) node; if (keys.hasNext()) { JsonNode child = obj.get(key); if (child == null) { child = obj.objectNode(); obj.put(key, child); } node = child; } else { if (obj.get(key) != null && obj.get(key).isArray()) { final Iterator<String> values = Splitter.on('|').trimResults().split(value).iterator(); ArrayNode arrayNode = (ArrayNode) obj.get(key); arrayNode.removeAll(); while (values.hasNext()) arrayNode.add (values.next()); } else { obj.put(key, value); } } } }

Target:
private void addOverride(JsonNode root, String name, String value) { JsonNode node = root; final Iterator<String> keys = Splitter.on('.').trimResults().split(name).iterator(); while (keys.hasNext()) { final String key = keys.next(); if (!(node instanceof ObjectNode)) { throw new IllegalArgumentException("Unable to override " + name + "; it's not a valid path."); } final ObjectNode obj = (ObjectNode) node; if (keys.hasNext()) { JsonNode child = obj.get(key); if (child == null) { child = obj.objectNode(); obj.put(key, child); } node = child; } else { if (obj.get(key) != null && obj.get(key).isArray()) { ArrayNode arrayNode = (ArrayNode) obj.get(key); arrayNode.removeAll(); Pattern escapedComma = Pattern.compile("\\\\,"); for (String val : Splitter.on(Pattern.compile("(?<!\\\\),")).trimResults().split(value)) arrayNode.add (escapedComma.matcher(val).replaceAll(",")); } else { obj.put(key, value); } } } }
Source:
public ColdMergeCommandParameters(Guid storagePoolId, SubchainInfo subchainInfo) { super(); setStoragePoolId(storagePoolId); this.subchainInfo = subchainInfo; }

Target:
public ColdMergeCommandParameters(Guid storagePoolId, SubchainInfo subchainInfo) { setStoragePoolId(storagePoolId); this.subchainInfo = subchainInfo; }
Source:
private static Type getExistingSpecial(StructuralFeature structuralFeature) { Set<Type> types = new HashSet<Type>(); Element owner = structuralFeature.getOwner(); for(RedefinableElement redef : structuralFeature.getRedefinedElement()){ if(redef instanceof TypedElement){ types.add(((TypedElement) redef).getType()); System.out.println("Found type: "+((TypedElement) redef).getType().getName() +" id "+ ((TypedElement) redef).getType().toString() + " for SF " + structuralFeature.getName() + " " + structuralFeature.toString()); } } for(Element oe : owner.getOwnedElement()){ if(oe instanceof Property){ if(!oe.equals(structuralFeature)){ for(RedefinableElement redef : ((Property) oe).getRedefinedElement()){ if(redef instanceof TypedElement) { if (types.contains(((TypedElement) redef).getType())) { System.out.println("Found type: "+((TypedElement) oe).getType().getName() +" id "+ ((TypedElement) oe).getType().toString() + " for SF " + redef.getName() + " " + redef.toString()); return ((Property) oe).getType(); } } } } } } return null; }

Target:
private static Type getExistingSpecial(StructuralFeature structuralFeature) { Set<Type> types = new HashSet<Type>(); Element owner = structuralFeature.getOwner(); for(RedefinableElement redef : structuralFeature.getRedefinedElement()){ if(redef instanceof TypedElement){ types.add(((TypedElement) redef).getType()); } } for(Element oe : owner.getOwnedElement()){ if(oe instanceof Property){ if(!oe.equals(structuralFeature)){ for(RedefinableElement redef : ((Property) oe).getRedefinedElement()){ if(redef instanceof TypedElement) { if (types.contains(((TypedElement) redef).getType())) { return ((Property) oe).getType(); } } } } } } return null; }