Skip to content

Commit

Permalink
Specifying generic types
Browse files Browse the repository at this point in the history
In this commit, I am specifying generic types where they were not
specified. I used the SonarCloud report as a reference to know where
to specify.
  • Loading branch information
Bhavya031 authored and cbosdo committed Sep 4, 2023
1 parent 0ea6b73 commit ce48554
Show file tree
Hide file tree
Showing 95 changed files with 210 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@


/**
* Elaboratable
* Elaborator
*/
public interface Elaborator extends Serializable {

/**
* Returns an elaborated list for the given List of objects
* @param objectsToElaborate the list of objects to elaborate
*/
void elaborate(List objectsToElaborate);
void elaborate(List<Object> objectsToElaborate);

/**
* Returns an elaborated list for the given List of objects with an updated session
* @param objectsToElaborate the list of objects to elaborate
* @param session session to use
*/
void elaborate(List objectsToElaborate, Session session);
void elaborate(List<Object> objectsToElaborate, Session session);
}
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public boolean isInitialized() {
return connectionManager.isInitialized();
}

protected DataResult executeSelectMode(String name, String mode, Map params) {
protected DataResult executeSelectMode(String name, String mode, Map<String, Object> params) {
SelectMode m = ModeFactory.getMode(name, mode);
return m.execute(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void parseURL(URL u) {
* be public or Digester freaks out, otherwise it would be private.
* @param m used by Digester to build template
*/
public void addFactoryTemplate(Map m) {
public void addFactoryTemplate(Map<String, Object> m) {
String name = (String)m.get("name");
if (name == null) {
throw new NullPointerException("factory/template must have name attribute");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface ManifestFactoryBuilder {
* @param param Map of parameters to produce this Factory by
* @return Object Object created by Factory
*/
Object createObject(Map param);
Object createObject(Map<String, Object> param);

/** get the filename associated with this builder
* TODO: probably should be a URL instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public ValidatorResult validateObject(Object validateIn, Validator validatorIn)
* @return ValidatorResult
*/
public ValidatorResult validateObject(Object validateIn, Validator validatorIn,
List constraintNames) {
List<String> constraintNames) {

ValidatorResult result = new ValidatorResult();
for (Object oIn : validatorIn.getConstraints()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -194,7 +195,7 @@ protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,

Elaborator elaborator = TagHelper.lookupElaboratorFor(getUniqueName(request), request);
if (elaborator != null) {
elaborator.elaborate(pageData, HibernateFactory.getSession());
elaborator.elaborate(pageData.stream().collect(Collectors.toList()), HibernateFactory.getSession());
}

String contentType = csvWriter.getMimeType() + ";charset=" + response.getCharacterEncoding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
Enumeration paramNames;
Enumeration<String> paramNames;
ListHelper helper = new ListHelper(this, request);
Map forwardParams = makeParamMap(request);
Map<String, Object> forwardParams = makeParamMap(request);
String str;

helper.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public ActionForward execute(ActionMapping mapping,
HttpServletRequest request,
HttpServletResponse response) {
ActionMessages amsgs;
Enumeration paramNames;
Enumeration<String> paramNames;
ListHelper helper = new ListHelper(this, request);
Long start, end;
Map forwardParams = makeParamMap(request);
Map<String, Object> forwardParams = makeParamMap(request);
RequestContext requestContext = new RequestContext(request);
String str, reviewed, machine, username;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private DateRangePicker.DatePickerResults processTimeArgs(
return dpresults;
}

private List prepareAuditTypes() {
private List<String> prepareAuditTypes() {
BufferedReader brdr;
LinkedList<String> typelist;
Process proc;
Expand Down Expand Up @@ -167,7 +167,7 @@ public ActionForward execute(ActionMapping mapping,
DynaActionForm dform = (DynaActionForm)form;
HttpSession session = request.getSession(true);
JSONWriter jsonwr = new JSONWriter();
List result = null;
List<String> result = null;
Long start, end, seqno, cacheSeqno;
Map<String, String[]> typemap;
RequestContext requestContext = new RequestContext(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.redhat.rhn.common.util.DatePicker;
import com.redhat.rhn.frontend.action.BaseSearchAction;
import com.redhat.rhn.frontend.action.common.DateRangePicker;
import com.redhat.rhn.frontend.dto.BaseDto;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.frontend.taglibs.list.TagHelper;
Expand Down Expand Up @@ -64,7 +65,7 @@ protected ActionForward doExecute(HttpServletRequest request, ActionMapping mapp

if (!StringUtils.isBlank(searchString)) {
picker.processDatePickers(getOptionScanDateSearch(request), false);
DataResult results = XccdfSearchHelper.performSearch(searchString,
DataResult<BaseDto> results = XccdfSearchHelper.performSearch(searchString,
whereToSearch, getPickerDate(request, "start"),
getPickerDate(request, "end"), getRuleResultLabel(form),
isTestestResultRequested(form), context);
Expand Down Expand Up @@ -151,7 +152,7 @@ protected void insureFormDefaults(HttpServletRequest request, DynaActionForm for
"system_list".equals(whereToSearch) ? whereToSearch : "all");
setupRuleResultLabelOptions(request);
setupShowAsOption(form);
Map m = form.getMap();
Map<String, Object> m = form.getMap();
Set<String> keys = m.keySet();
for (String key : keys) {
Object vObj = m.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.frontend.dto.BaseDto;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.manager.audit.ScapManager;
Expand Down Expand Up @@ -56,26 +57,26 @@ public class XccdfSearchHelper extends RhnAction {
* @throws XmlRpcException in the case of a serialization failure
* @throws XmlRpcFault bad communication with search server
*/
public static DataResult performSearch(String searchString, String whereToSearch,
Date startDate, Date endDate, String ruleResult, boolean returnTestResults,
RequestContext context)
public static DataResult<BaseDto> performSearch(String searchString, String whereToSearch,
Date startDate, Date endDate, String ruleResult,
boolean returnTestResults, RequestContext context)
throws MalformedURLException, XmlRpcException, XmlRpcFault {
ArrayList args = new ArrayList<>();
ArrayList<Object> args = new ArrayList<>();
args.add(context.getWebSession().getId().toString());
args.add(IDENT_INDEX);
args.add(preprocessSearchString(searchString));
args.add(true); //fine grained
List searchResult = invokeSearchServer(INDEX_SEARCH, args);
args.add(Boolean.TRUE); // convert boolean to String
List<Map<String, Object>> searchResult = invokeSearchServer(INDEX_SEARCH, args);
// searchResult contains id to rhnXccdfIdent relation,
// while we want to return RuleResults
List<Long> identIds = new ArrayList<>();
for (int x = searchResult.size() - 1; x >= 0; x--) {
Map item = (Map) searchResult.get(x);
Map<String, Object> item = searchResult.get(x);
Long id = Long.valueOf((String)item.get("id"));
identIds.add(id);
}

Map params = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
params.put("user_id", context.getCurrentUser().getId());
if (SYSTEM_LIST.equals(whereToSearch)) {
params.put("slabel", SYSTEM_LIST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private ActionForward processForm(ActionMapping mapping,
msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.xccdfeval.ssm"));
strutsDelegate.saveMessages(request, msgs);

Map paramMap = makeParamMap(request);
Map<String, Object> paramMap = makeParamMap(request);
paramMap.put("aid", scapAction.getId());
return strutsDelegate.forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD),
paramMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ActionForward execute(ActionMapping mapping,
DynaActionForm form = (DynaActionForm)formIn;
RequestContext ctx = new RequestContext(request);
User user = ctx.getCurrentUser();
Map params = makeParamMap(request);
Map<String, Object> params = makeParamMap(request);
String fwd = RhnHelper.DEFAULT_FORWARD;

long cid = ctx.getRequiredParam("cid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static List<PackageOverview> performSearch(Long sessionId, String searchS
args.add("package");
args.add(preprocessSearchString(searchString, mode, pkgArchLabels));
args.add(fineGrained);
List results = (List)client.invoke("index.search", args);
List<Map<String, Object>> results = (List<Map<String, Object>>)client.invoke("index.search", args);

if (log.isDebugEnabled()) {
log.debug("results = [{}]", results);
Expand All @@ -101,10 +101,9 @@ public static List<PackageOverview> performSearch(Long sessionId, String searchS

List<Long> pids = new ArrayList<>();
Set<String> names = new HashSet<>();
for (Object itemObject : results) {
Map item = (Map) itemObject;
for (Map<String, Object> item : results) {
names.add((String) item.get("name"));
Long pid = Long.valueOf((String)item.get("id"));
Long pid = Long.valueOf((String) item.get("id"));
pids.add(pid);
}

Expand Down Expand Up @@ -146,9 +145,8 @@ public static List<PackageOverview> performSearch(Long sessionId, String searchS

// Iterate through in the order that the search server returned, add packages
// to the return list in the order they appear in the search results.
for (Object resultObject : results) {
Map result = (Map) resultObject;
Long pid = Long.valueOf((String)result.get("id"));
for (Map<String, Object> result : results) {
Long pid = Long.valueOf((String) result.get("id"));
if (pidToPackageMap.get(pid) != null) {
ordered.add(pidToPackageMap.get(pid));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ private String findVersionFromChannel(Channel channel) {
}


private List findChannelsByVersion(User user, String version) {
private List<Channel> findChannelsByVersion(User user, String version) {

if (version == null) {
return null;
}
List<Channel> channels = ChannelFactory.listRedHatBaseChannels(user);
List toReturn = new ArrayList<>();
List<Channel> toReturn = new ArrayList<>();
for (Channel chan : channels) {
for (DistChannelMap map : chan.getDistChannelMaps()) {
if (ChannelVersion.getChannelVersionForDistChannelMap(map).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ActionForward execute(ActionMapping mapping,
request.setAttribute("is_custom", currentChan.isCustom());
request.setAttribute(RequestContext.CID, cid);

Map params = makeParamMap(request);
Map<String, Object> params = makeParamMap(request);
params.put(RequestContext.CID, cid);

ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ActionForward execute(ActionMapping mapping,
request.setAttribute("channel_name", currentChan.getName());
request.setAttribute(RequestContext.CID, cid);

Map params = makeParamMap(request);
Map<String, Object> params = makeParamMap(request);
params.put(RequestContext.CID, cid);

ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public ActionForward operateOnSelectedSet(ActionMapping mapping,
return handleEmptySelection(mapping, formIn, request);
}

Map params = makeParamMap(formIn, request);
Map<String, Object> params = makeParamMap(formIn, request);
RequestContext rctx = new RequestContext(request);
User user = rctx.getCurrentUser();

StrutsDelegate strutsDelegate = getStrutsDelegate();

int successCount = 0;
int failureCount = 0;
for (Iterator i = set.getElements().iterator(); i.hasNext();) {
RhnSetElement element = (RhnSetElement) i.next();
for (Iterator<RhnSetElement> i = set.getElements().iterator(); i.hasNext();) {
RhnSetElement element = i.next();
boolean success = callMethod(callbackMethodName,
new Object[] {formIn,
request,
Expand Down Expand Up @@ -126,7 +126,7 @@ protected ActionForward handleEmptySelection(ActionMapping mapping,

StrutsDelegate strutsDelegate = getStrutsDelegate();

Map params = makeParamMap(formIn, request);
Map<String, Object> params = makeParamMap(formIn, request);
ActionMessages msg = new ActionMessages();
msg.add(ActionMessages.GLOBAL_MESSAGE, getEmptySelectionMessage());
strutsDelegate.saveMessages(request, msg);
Expand Down Expand Up @@ -162,7 +162,7 @@ public ActionForward handleNoScript(ActionMapping mapping,
msg.add(ActionMessages.GLOBAL_MESSAGE, getNoScriptMessage());
strutsDelegate.saveMessages(request, msg);

Map params = makeParamMap(formIn, request);
Map<String, Object> params = makeParamMap(formIn, request);
String forward = getForwardName(request);
return strutsDelegate.forwardParams(mapping.findForward(forward), params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public abstract class BaseAddFilesAction extends RhnAction {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {

Map params = makeParamMap(request);
Map<String, Object> params = makeParamMap(request);
ConfigFileForm cff = (ConfigFileForm) form;

processRequest(request);
Expand Down Expand Up @@ -96,7 +96,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm form,
*/
protected boolean passesValidation(HttpServletRequest req,
ConfigFileForm cff, ActionMapping mapping, ConfigChannel channel,
Map params) {
Map<String, Object> params) {

RhnValidationHelper.setFailedValidation(req);
// File-upload errors? Bug out if so
Expand All @@ -113,7 +113,7 @@ protected boolean passesValidation(HttpServletRequest req,

protected ActionForward doCreate(HttpServletRequest req,
DynaActionForm form, ActionMapping mapping, ConfigChannel channel,
Map params) {
Map<String, Object> params) {

ConfigFileForm cff = (ConfigFileForm) form;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private ActionForward prepareToLeave(ActionMapping mapping, HttpServletRequest r
ActionChainHelper.prepopulateActionChains(req);

ConfigActionHelper.setupRequestAttributes(ctx, cc);
Map m = makeParamMap(req);
Map<String, Object> m = makeParamMap(req);
return getStrutsDelegate().forwardParams(mapping.findForward(forwardLabel), m);
}

Expand Down Expand Up @@ -139,7 +139,7 @@ private ConfigChannel setupLists(HttpServletRequest request, User user) {

@Override
protected Map makeParamMap(HttpServletRequest request) {
Map m = super.makeParamMap(request);
Map<String, Object> m = super.makeParamMap(request);
ConfigChannel cc = ConfigActionHelper.getChannel(request);
ConfigActionHelper.processParamMap(cc, m);
return m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void processRequestAttributes(RequestContext rctx) {

@Override
protected Map makeParamMap(HttpServletRequest request) {
Map m = super.makeParamMap(request);
Map<String, Object> m = super.makeParamMap(request);
ConfigChannel cc = ConfigActionHelper.getChannel(request);
ConfigActionHelper.processParamMap(cc, m);
return m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ActionForward doAll(
HttpServletRequest request,
HttpServletResponse response) {
selectall(mapping, formIn, request, response);
Map params = makeParamMap(formIn, request);
Map<String, Object> params = makeParamMap(formIn, request);
return getStrutsDelegate().forwardParams(mapping.findForward("success"), params);
}

Expand All @@ -102,7 +102,7 @@ public ActionForward doSelected(
if (set.isEmpty()) {
return handleEmptySelection(mapping, formIn, request);
}
Map params = makeParamMap(formIn, request);
Map<String, Object> params = makeParamMap(formIn, request);
return getStrutsDelegate().forwardParams(mapping.findForward("success"), params);
}
}
Loading

0 comments on commit ce48554

Please sign in to comment.