Skip to content

Commit

Permalink
[NETBEANS-2621] cleanup generic class iterator
Browse files Browse the repository at this point in the history
reduce the # of instances of the following error..

   [repeat] /home/bwalker/netbeans-11.0/platform/core.startup/src/org/
     netbeans/core/startup/AutomaticDependencies.java:372: warning: [rawtypes] found raw type: Iterator
   [repeat]             Iterator it = exclusions.iterator();
   [repeat]             ^
   [repeat]   missing type arguments for generic class Iterator<E>
   [repeat]   where E is a type-variable:
   [repeat]     E extends Object declared in interface Iterator
  • Loading branch information
BradWalker authored and matthiasblaesing committed Jun 9, 2019
1 parent 3b41f3d commit fb01691
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,7 @@ public void removeCatalogListener(CatalogListener l) {
}

public void fireCatalogListeners() {
Iterator iter = catalogListeners.iterator();
while (iter.hasNext()) {
CatalogListener l = (CatalogListener) iter.next();
for (CatalogListener l : catalogListeners) {
l.notifyInvalidate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,14 @@ private void compute() {
int currentOffset = 4+4+4;

// compute offset of classes
for (Iterator it = classInfo.values().iterator(); it.hasNext(); ) {
ClassInfo info = (ClassInfo)it.next();
for (ClassInfo info : classInfo.values()) {
currentOffset = info.computeNextOffset(currentOffset);
}

refsOffset = currentOffset;

// compute offsets of refs
for (Iterator it = refInfo.values().iterator(); it.hasNext(); ) {
RefInfo info = (RefInfo)it.next();
for (RefInfo info : refInfo.values()) {
currentOffset = info.computeNextOffset(currentOffset);
}

Expand All @@ -367,14 +365,12 @@ private void storeHeaders() throws IOException {
store.putInt(objsOffset);

// store classes
for (Iterator it = classInfo.values().iterator(); it.hasNext(); ) {
ClassInfo info = (ClassInfo)it.next();
for (ClassInfo info : classInfo.values()) {
info.storeHeader();
}

// store refs
for (Iterator it = refInfo.values().iterator(); it.hasNext(); ) {
RefInfo info = (RefInfo)it.next();
for (RefInfo info : refInfo.values()) {
info.storeHeader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ private static void createStatusProviders(Collection<? extends UpToDateStatusPro
}

private void addListenersToStatusProviders() {
for (Iterator p = statusProviders.iterator(); p.hasNext(); ) {
UpToDateStatusProvider provider = (UpToDateStatusProvider) p.next();
for (UpToDateStatusProvider provider : statusProviders) {

// removePropertyChangeListener() is non-public but present in UpToDateStatusProvider - will the weak listener removal work??
PropertyChangeListener weakL = WeakListeners.propertyChange(this, provider);
Expand All @@ -242,9 +241,7 @@ private void addListenersToStatusProviders() {
}

private void addListenersToMarkProviders() {
for (Iterator p = markProviders.iterator(); p.hasNext(); ) {
MarkProvider provider = (MarkProvider) p.next();

for (MarkProvider provider : markProviders) {
PropertyChangeListener weakL = WeakListeners.propertyChange(this, provider);
provider.addPropertyChangeListener(weakL);
statusProvidersWeakLs.add(weakL);
Expand Down Expand Up @@ -474,8 +471,7 @@ public UpToDateStatus computeTotalStatusType() {

UpToDateStatus statusType = UpToDateStatus.UP_TO_DATE_OK;

for (Iterator p = statusProviders.iterator(); p.hasNext(); ) {
UpToDateStatusProvider provider = (UpToDateStatusProvider) p.next();
for ( UpToDateStatusProvider provider : statusProviders) {
UpToDateStatus newType = provider.getUpToDate();

if (newType.compareTo(statusType) > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,7 @@ public static void putJavaCompilationUnits(AntProjectHelper helper,
}
}
if (cu.javadoc != null) {
Iterator it3 = cu.javadoc.iterator();
while (it3.hasNext()) {
String javadoc = (String) it3.next();
for (String javadoc : cu.javadoc) {
assert JavaProjectNature.namespaceAtLeast(namespace, JavaProjectNature.NS_JAVA_2);
el = doc.createElementNS(data.getNamespaceURI(), "javadoc-built-to"); // NOI18N
el.appendChild(doc.createTextNode(javadoc));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,8 @@ public String toString() {
* Is the given code name base excluded from this group of transformations?
*/
public boolean isExcluded(String cnb) {
Iterator it = exclusions.iterator();
while (it.hasNext()) {
if (((Exclusion)it.next()).matches(cnb)) {
for (Exclusion e : exclusions) {
if (e.matches(cnb)) {
return true;
}
}
Expand Down Expand Up @@ -406,10 +405,9 @@ public void apply(Map<String, Dependency> modDeps,
} else {
throw new IllegalStateException(triggerType);
}

// Add in results.
Iterator it = results.iterator();
while (it.hasNext()) {
Dep nue = (Dep)it.next();
for (Dep nue : results) {
nue.update(modDeps, tokDeps, pkgDeps, dependencies);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public void writeSettings(Properties p, String propertyPrefix) {
int i = 0;
int numColumns = tableColumns.size();
p.setProperty(propertyPrefix + NUMBER_OF_COLUMNS, Integer.toString(numColumns));
for (Iterator it = tableColumns.iterator(); it.hasNext(); ) {
Object obj = it.next();
for (Object obj : tableColumns) {
if (obj instanceof ETableColumn) {
ETableColumn etc = (ETableColumn) obj;
etc.writeSettings(p, i++, propertyPrefix);
Expand All @@ -138,8 +137,7 @@ public void writeSettings(Properties p, String propertyPrefix) {
i = 0;
int numHiddenColumns = hiddenColumns.size();
p.setProperty(propertyPrefix + NUMBER_OF_HIDDEN_COLUMNS, Integer.toString(numHiddenColumns));
for (Iterator it = hiddenColumns.iterator(); it.hasNext(); ) {
Object obj = it.next();
for (Object obj : hiddenColumns) {
if (obj instanceof ETableColumn) {
ETableColumn etc = (ETableColumn) obj;
etc.writeSettings(p, i++, propertyPrefix + PROP_HIDDEN_PREFIX);
Expand Down Expand Up @@ -390,8 +388,7 @@ public boolean isColumnHidden(TableColumn tc) {
*/
@SuppressWarnings("deprecation")
public void clearSortedColumns() {
for (Iterator it = sortedColumns.iterator(); it.hasNext(); ) {
Object o = it.next();
for (Object o : sortedColumns) {
if (o instanceof ETableColumn) {
ETableColumn etc = (ETableColumn)o;
etc.setSorted(0, false);
Expand All @@ -406,8 +403,7 @@ public void clearSortedColumns() {
@SuppressWarnings("deprecation")
void clearSortedColumns(TableColumn notThisOne) {
boolean wasSorted = sortedColumns.contains(notThisOne);
for (Iterator it = sortedColumns.iterator(); it.hasNext(); ) {
Object o = it.next();
for (Object o : sortedColumns) {
if ((o instanceof ETableColumn) && (o != notThisOne)) {
ETableColumn etc = (ETableColumn)o;
etc.setSorted(0, false);
Expand All @@ -424,8 +420,7 @@ void clearSortedColumns(TableColumn notThisOne) {
*/
private void updateRanks() {
int i = 1;
for (Iterator it = sortedColumns.iterator(); it.hasNext(); i++) {
Object o = it.next();
for (Object o : sortedColumns) {
if (o instanceof ETableColumn) {
ETableColumn etc = (ETableColumn)o;
if (etc.isSorted()) {
Expand Down Expand Up @@ -464,8 +459,7 @@ public CompoundComparator() {
}
@Override
public int compare(RowMapping o1, RowMapping o2) {
for (Iterator it = sortedColumns.iterator(); it.hasNext(); ) {
Object o = it.next();
for (Object o : sortedColumns) {
if (o instanceof ETableColumn) {
ETableColumn etc = (ETableColumn)o;
Comparator<RowMapping> c = etc.getComparator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ private void update() {
}

Iterator it = now.iterator();

while (it.hasNext()) {
FileObject fo = (FileObject) it.next();
fo.removeFileChangeListener(weakL);
Expand Down Expand Up @@ -1757,10 +1756,7 @@ private FileLock getCurrentMfLock() {
}

private void releaseLockForDelegates() {
Iterator it = map.values().iterator();

while (it.hasNext()) {
FileLock l = (FileLock) it.next();
for (FileLock l : map.values()) {
l.releaseLock();
}

Expand Down

0 comments on commit fb01691

Please sign in to comment.