Skip to content

Commit

Permalink
Merge pull request #7552 from BradWalker/cleanup_redundant_casts
Browse files Browse the repository at this point in the history
Reduce redundant cast warnings. These happen as a side result of code cleanup..

Reduce warnings that look like this:

[repeat] /home/bwalker/src/netbeans/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/util/LogManager.java:271: warning: [cast] redundant cast to LogViewer
[repeat] contextLog = (LogViewer)contextLogViewers.get(moduleID);
[repeat] ^Cleanup redundant casts. These are a side effect of work done doing code cleanup.
  • Loading branch information
BradWalker committed Jul 8, 2024
2 parents 94a916c + 113e2ce commit d66c5df
Show file tree
Hide file tree
Showing 35 changed files with 54 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected void drawStringToGraphics(Graphics g, String s, Font font, boolean str
}

protected int getWidth(String s) {
Integer i = (Integer)widths.get(s);
Integer i = widths.get(s);
if (i != null) {
return i;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public HashMap<String,Map> getSunDatasourcesFromXml(){

private Map<String,String> getPoolValues(Map<String, Node> cpMap, String poolName) {
Map<String,String> pValues = new HashMap<>();
Node cpNode = (Node) cpMap.get(poolName);
Node cpNode = cpMap.get(poolName);
NamedNodeMap cpAttrMap = cpNode.getAttributes();
Node dsClassName = cpAttrMap.getNamedItem(CONST_DS_CLASS);
Node resType = cpAttrMap.getNamedItem(CONST_RES_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ private static NbProcessDescriptor defaultDebugStartDesc(String command, String
}

private String getJavaHome(JavaPlatform platform) {
FileObject fo = (FileObject)platform.getInstallFolders().iterator().next();
FileObject fo = platform.getInstallFolders().iterator().next();
return FileUtil.toFile(fo).getAbsolutePath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void openContextLog(TomcatModule module) {
if (!moduleConfig.hasLogger()) {
return;
}
contextLog = (LogViewer)contextLogViewers.get(moduleID);
contextLog = contextLogViewers.get(moduleID);
LogViewer newContextLog = null;
try {
newContextLog = new LogViewer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static ActionsProvider getActionProvider(String folderPath) {
}

synchronized (dataFolder2actionsProvider) {
ActionsProvider actionsProvider = (ActionsProvider)dataFolder2actionsProvider.get(dataFolder);
ActionsProvider actionsProvider = dataFolder2actionsProvider.get(dataFolder);
if (actionsProvider == null) {
actionsProvider = new DefaultActionsProvider(dataFolder);
dataFolder2actionsProvider.put(dataFolder, actionsProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static boolean removeParametersFromQuery(RequestData rd) {
Enumeration<String> e = ht.keys();

while(e.hasMoreElements()) {
String name = (String)e.nextElement();
String name = e.nextElement();
try {
String[] value = (String[])(ht.get(name));
for(int i=0; i<value.length; ++i) {
Expand Down Expand Up @@ -141,7 +141,7 @@ static void addParametersToQuery(RequestData rd) {
if(ht != null && ht.size() > 0) {
Enumeration<String> e = ht.keys();
while(e.hasMoreElements()) {
String name = (String)e.nextElement();
String name = e.nextElement();
String[] value = (String[])(ht.get(name));
for(int i=0; i<value.length; ++i) {
if(debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ private FileObject[] findJsps(Lookup context) {
}

private boolean isDebugged() {
J2eeModuleProvider jmp = (J2eeModuleProvider) getWebProject().getLookup().lookup(J2eeModuleProvider.class);
J2eeModuleProvider jmp = getWebProject().getLookup().lookup(J2eeModuleProvider.class);
Session[] sessions = DebuggerManager.getDebuggerManager().getSessions();
ServerDebugInfo sdi = null;
if (sessions != null && sessions.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String getVersion() {

@Override
public Boolean isJPAVersionSupported(String version) {
J2eeModuleProvider j2eeModuleProvider = (J2eeModuleProvider) project.getLookup().lookup(J2eeModuleProvider.class);
J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
J2eePlatform platform = Deployment.getDefault().getJ2eePlatform(j2eeModuleProvider.getServerInstanceID());

if (platform == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public Void run() throws Exception {

ep.setProperty(WebProjectProperties.JAVA_SOURCE_BASED,javaSourceBased+"");

UpdateHelper updateHelper = ((WebProject) p).getUpdateHelper();
UpdateHelper updateHelper = p.getUpdateHelper();

// this enforcement is valid only for Web project for EE 6; non-EE6 containers may support JDK 7
// // #181215: JDK 6 should be the default source/binary format for Java EE 6 projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ else if (create) {
@Override
public String getWsdlLocation(String serviceName) {
String localWsdl = serviceName+".wsdl"; //NOI18N
JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class);
JaxWsModel jaxWsModel = project.getLookup().lookup(JaxWsModel.class);
if (jaxWsModel!=null) {
Service service = jaxWsModel.findServiceByName(serviceName);
if (service!=null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ConfFilesNodeFactory() {
}

public NodeList createNodes(Project p) {
WebProject project = (WebProject) p.getLookup().lookup(WebProject.class);
WebProject project = p.getLookup().lookup(WebProject.class);
assert project != null;
return new ConfFilesNodeList(project);
}
Expand All @@ -111,7 +111,7 @@ private static class ConfFilesNodeList implements NodeList<String>, PropertyChan

ConfFilesNodeList(WebProject proj) {
project = proj;
WebLogicalViewProvider logView = (WebLogicalViewProvider) project.getLookup().lookup(WebLogicalViewProvider.class);
WebLogicalViewProvider logView = project.getLookup().lookup(WebLogicalViewProvider.class);
assert logView != null;
}

Expand Down Expand Up @@ -283,7 +283,7 @@ private void setGroups(Collection groups) {
Iterator it = groupsListeners.keySet().iterator();
while (it.hasNext()) {
SourceGroup group = (SourceGroup) it.next();
PropertyChangeListener pcl = (PropertyChangeListener) groupsListeners.get(group);
PropertyChangeListener pcl = groupsListeners.get(group);
group.removePropertyChangeListener(pcl);
}
}
Expand All @@ -306,7 +306,7 @@ protected void setFiles(Set files) {
Iterator it = fileSystemListeners.keySet().iterator();
while (it.hasNext()) {
FileSystem fs = (FileSystem) it.next();
FileStatusListener fsl = (FileStatusListener) fileSystemListeners.get(fs);
FileStatusListener fsl = fileSystemListeners.get(fs);
fs.removeFileStatusListener(fsl);
}
}
Expand Down Expand Up @@ -357,8 +357,7 @@ private ConfFilesChildrenFactory(ProjectWebModule webModule) {
}

public static ConfFilesChildrenFactory forProject(Project project) {
ProjectWebModule pwm = (ProjectWebModule) project.getLookup().lookup(
ProjectWebModule.class);
ProjectWebModule pwm = project.getLookup().lookup(ProjectWebModule.class);
return new ConfFilesChildrenFactory(pwm);
}

Expand Down Expand Up @@ -531,7 +530,7 @@ private boolean addFrameworkFiles( ) {
boolean result = false;
start :
for (int i = 0; i < providers.size(); i++) {
WebFrameworkProvider provider = (WebFrameworkProvider) providers.get(i);
WebFrameworkProvider provider = providers.get(i);
FileObject wmBase = getWebModule().getDocumentBase();
File[] files = null;
if (wmBase != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ private void init() {
EditableProperties projectProperties = updateHelper.getProperties( AntProjectHelper.PROJECT_PROPERTIES_PATH );
EditableProperties privateProperties = updateHelper.getProperties( AntProjectHelper.PRIVATE_PROPERTIES_PATH );

JAVAC_CLASSPATH_MODEL = ClassPathTableModel.createTableModel( cs.itemsIterator( (String)projectProperties.get( ProjectProperties.JAVAC_CLASSPATH ), ClassPathSupportCallbackImpl.TAG_WEB_MODULE_LIBRARIES) );
JAVAC_CLASSPATH_MODEL = ClassPathTableModel.createTableModel( cs.itemsIterator(projectProperties.get( ProjectProperties.JAVAC_CLASSPATH ), ClassPathSupportCallbackImpl.TAG_WEB_MODULE_LIBRARIES) );
String processorPath = projectProperties.get(ProjectProperties.JAVAC_PROCESSORPATH);
processorPath = processorPath == null ? "${javac.classpath}" : processorPath;
JAVAC_PROCESSORPATH_MODEL = ClassPathUiSupport.createListModel(cs.itemsIterator(processorPath));
JAVAC_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator( (String)projectProperties.get( ProjectProperties.JAVAC_TEST_CLASSPATH ), null ) );
RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator( (String)projectProperties.get( ProjectProperties.RUN_TEST_CLASSPATH ), null ) );
ENDORSED_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator( (String)projectProperties.get( ProjectProperties.ENDORSED_CLASSPATH ), null ) );
JAVAC_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator(projectProperties.get( ProjectProperties.JAVAC_TEST_CLASSPATH ), null ) );
RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator(projectProperties.get( ProjectProperties.RUN_TEST_CLASSPATH ), null ) );
ENDORSED_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator(projectProperties.get( ProjectProperties.ENDORSED_CLASSPATH ), null ) );
PLATFORM_MODEL = PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM));
PLATFORM_LIST_RENDERER = PlatformUiSupport.createPlatformListCellRenderer();
SpecificationVersion minimalSourceLevel = null;
Expand Down Expand Up @@ -427,7 +427,7 @@ private void init() {
WAR_NAME_MODEL = projectGroup.createStringDocument( evaluator, WAR_NAME );
BUILD_CLASSES_EXCLUDES_MODEL = projectGroup.createStringDocument( evaluator, BUILD_CLASSES_EXCLUDES );
WAR_COMPRESS_MODEL = projectGroup.createToggleButtonModel( evaluator, WAR_COMPRESS );
WAR_CONTENT_ADDITIONAL_MODEL = WarIncludesTableModel.createTableModel( cs.itemsIterator( (String)projectProperties.get( WAR_CONTENT_ADDITIONAL ), ClassPathSupportCallbackImpl.TAG_WEB_MODULE__ADDITIONAL_LIBRARIES));
WAR_CONTENT_ADDITIONAL_MODEL = WarIncludesTableModel.createTableModel( cs.itemsIterator(projectProperties.get( WAR_CONTENT_ADDITIONAL ), ClassPathSupportCallbackImpl.TAG_WEB_MODULE__ADDITIONAL_LIBRARIES));

// CustomizerJavadoc
JAVADOC_PRIVATE_MODEL = projectGroup.createToggleButtonModel( evaluator, JAVADOC_PRIVATE );
Expand Down Expand Up @@ -483,7 +483,7 @@ public void actionPerformed(ActionEvent e) {
try {
CONTEXT_PATH_MODEL = new PlainDocument();
CONTEXT_PATH_MODEL.remove(0, CONTEXT_PATH_MODEL.getLength());
ProjectWebModule wm = (ProjectWebModule) project.getLookup().lookup(ProjectWebModule.class);
ProjectWebModule wm = project.getLookup().lookup(ProjectWebModule.class);
String contextPath = wm.getContextPath();
if (contextPath != null) {
CONTEXT_PATH_MODEL.insertString(0, contextPath, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static WebServicesClientView getWebServicesClientView(FileObject f) {
}
}

WebServicesClientViewProvider impl = (WebServicesClientViewProvider) Lookup.getDefault().lookup(WebServicesClientViewProvider.class);
WebServicesClientViewProvider impl = Lookup.getDefault().lookup(WebServicesClientViewProvider.class);
if(impl != null) {
WebServicesClientView wsv = impl.findWebServicesClientView(f);
return wsv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static JAXWSClientView getJAXWSClientView() {
}
}

JAXWSClientViewProvider impl = (JAXWSClientViewProvider) Lookup.getDefault().lookup(JAXWSClientViewProvider.class);
JAXWSClientViewProvider impl = Lookup.getDefault().lookup(JAXWSClientViewProvider.class);
if(impl != null) {
JAXWSClientView wsv = impl.findJAXWSClientView();
return wsv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ static JavaSource getJavaSourceFromClassName(Project p, String qualifiedClassNam
}

public static boolean supportsTargetProfile(Project project, Profile profile){
J2eeModuleProvider provider = (J2eeModuleProvider) project.getLookup().
lookup(J2eeModuleProvider.class);
J2eeModuleProvider provider = project.getLookup().lookup(J2eeModuleProvider.class);
String serverInstanceID = provider.getServerInstanceID();
if ( serverInstanceID == null ){
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private boolean containsClass(Collection<File> classpath, String className) thro
try {
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry entry = (JarEntry) entries.nextElement();
JarEntry entry = entries.nextElement();
if (classFilePath.equals(entry.getName())) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ boolean checkColumnNameForTable(Column col, String tableName) {
}
} else {
for (int icnt = 0; icnt < cols.size(); icnt++) {
if (columnName.equalsIgnoreCase((String) cols.get(icnt))) {
col.setColumnName(col.getColumnName(), (String) cols.get(icnt));
Log.getLogger().finest(" adjust colname to " + (String) cols.get(icnt));
if (columnName.equalsIgnoreCase(cols.get(icnt))) {
col.setColumnName(col.getColumnName(), cols.get(icnt));
Log.getLogger().finest(" adjust colname to " + cols.get(icnt));
if (col.getTableSpec() == null) {
col.setTableSpec(col.getTableSpec(), checkedTable);
Log.getLogger().finest(" adjust table to " + checkedTable);
Expand Down Expand Up @@ -435,8 +435,8 @@ List<String> getAllTables() throws SQLException {
// Convert from List<table, schema> to "table.schema", expected by query editor
List<String> result = new ArrayList<>();
for (List<String> fullTable : tables) {
String schema = (String) fullTable.get(0);
String table = (String) fullTable.get(1);
String schema = fullTable.get(0);
String table = fullTable.get(1);
result.add(((schema == null) || (schema.equals(""))) ? table : schema + "." + table);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ else if (source.getText().equals(NbBundle.getMessage(QueryBuilderInputTable.clas
}

private void setClipboard(String contents) {
ExClipboard clipboard = (ExClipboard) Lookup.getDefault().lookup(ExClipboard.class);
ExClipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
StringSelection strSel = new StringSelection(contents);
clipboard.setContents(strSel, strSel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public void run() {
try (JarFile jf = new JarFile(file)) {
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry entry = (JarEntry) entries.nextElement();
JarEntry entry = entries.nextElement();
String className = entry.getName();
if (className.endsWith(".class")) { // NOI18N
className = className.replace('/', '.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public String next() {
public boolean hasNext() {
if (list.size() > current) return true;
if (en.hasMoreElements()) {
String next = (String) en.nextElement();
String next = en.nextElement();
return list.add(next);
} else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public FileLock lock() throws IOException {

private synchronized FileLock getLock() {
// How this week reference can be useful ?
FileLock l = lockReference == null ? null : (FileLock) lockReference.get();
FileLock l = lockReference == null ? null : lockReference.get();
if (l != null && !l.isValid()) {
l = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ public void propertyChange(PropertyChangeEvent evt) {
if (mvtc == topComponent) {
if (en.hasMoreElements()) {
// Remember next cloned top component
mvtc = (CloneableTopComponent) en.nextElement();
mvtc = en.nextElement();
} else {
// All cloned top components are closed
notifyClosed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ private synchronized TreeEditorCookieImpl createEditor() { // atomic test and se
if (editor == null) {
return prepareEditor();
} else {
TreeEditorCookieImpl cached = (TreeEditorCookieImpl) editor.get();
TreeEditorCookieImpl cached = editor.get();
if (cached == null) {
return prepareEditor();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public Enumeration queryElements(HintContext ctx) {

// Finally we add xsl namespace elements with other prefixes than the first one
for (int prefixInd = 1; prefixInd < prefixList.size(); prefixInd++) {
String curPrefix = (String)prefixList.get(prefixInd) + ":"; // NOI18N
String curPrefix = prefixList.get(prefixInd) + ":"; // NOI18N
Node curNode = el;
String curName = null;
while(curNode != null && null != (curName = curNode.getNodeName()) && !curName.startsWith(curPrefix)) {
Expand Down Expand Up @@ -496,8 +496,8 @@ public Enumeration queryAttributes(HintContext ctx) {

String curXslPrefix = null;
for (int ind = 0; ind < prefixList.size(); ind++) {
if (elTagName.startsWith((String)prefixList.get(ind) + ":")){ // NOI18N
curXslPrefix = (String)prefixList.get(ind) + ":"; // NOI18N
if (elTagName.startsWith(prefixList.get(ind) + ":")){ // NOI18N
curXslPrefix = prefixList.get(ind) + ":"; // NOI18N
break;
}
}
Expand All @@ -512,7 +512,7 @@ public Enumeration queryAttributes(HintContext ctx) {
if (prefixList.size() > 0) {
Iterator it = getResultElementAttr().iterator();
while ( it.hasNext()) {
possibleAttributes.add((String)prefixList.get(0) + ":" + (String) it.next()); // NOI18N
possibleAttributes.add(prefixList.get(0) + ":" + (String) it.next()); // NOI18N
}
}
}
Expand Down Expand Up @@ -874,7 +874,7 @@ private void updateProperties(Node curNode) {

boolean outputFound = false;
if (prefixList.size() > 0) {
String outputElName = (String)prefixList.get(0) + ":output"; // NOI18N
String outputElName = prefixList.get(0) + ":output"; // NOI18N
Node childOfRoot = rootNode.getFirstChild();
while (childOfRoot != null) {
String childNodeName = childOfRoot.getNodeName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Enumeration enabled(GrammarEnvironment ctx) {
}
Enumeration<Node> en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
Node next = en.nextElement();
if (next.getNodeType() == Node.ELEMENT_NODE) {
Element root = (Element) next;
if ("project".equals(root.getNodeName())) { // NOI18N
Expand Down
Loading

0 comments on commit d66c5df

Please sign in to comment.