Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some raw type references #2589

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public class ManageFilePermissionsPage implements java.io.Serializable {
DataverseSession session;

Dataset dataset = new Dataset();
private final Map<RoleAssignee,List<RoleAssignmentRow>> roleAssigneeMap = new HashMap();
private final Map<DataFile,List<RoleAssignmentRow>> fileMap = new HashMap();
private final Map<AuthenticatedUser,List<DataFile>> fileAccessRequestMap = new HashMap();
private final Map<RoleAssignee,List<RoleAssignmentRow>> roleAssigneeMap = new HashMap<>();
private final Map<DataFile,List<RoleAssignmentRow>> fileMap = new HashMap<>();
private final Map<AuthenticatedUser,List<DataFile>> fileAccessRequestMap = new HashMap<>();

public Dataset getDataset() {
return dataset;
Expand Down Expand Up @@ -133,7 +133,7 @@ private void initMaps() {
if (file.isRestricted() || file.getFileMetadata().isRestricted()) {
// we get the direct role assignments assigned to the file
List<RoleAssignment> ras = roleService.directRoleAssignments(file);
List raList = new ArrayList<>(ras.size());
List<RoleAssignmentRow> raList = new ArrayList<>(ras.size());
for (RoleAssignment ra : ras) {
// for files, only show role assignments which can download
if (ra.getRole().permissions().contains(Permission.DownloadFile)) {
Expand All @@ -148,7 +148,7 @@ private void initMaps() {
for (AuthenticatedUser au : file.getFileAccessRequesters()) {
List<DataFile> requestedFiles = fileAccessRequestMap.get(au);
if (requestedFiles == null) {
requestedFiles = new ArrayList();
requestedFiles = new ArrayList<>();
fileAccessRequestMap.put(au, requestedFiles);
}

Expand All @@ -164,7 +164,7 @@ private void addFileToRoleAssignee(RoleAssignment assignment) {
RoleAssignee ra = roleAssigneeService.getRoleAssignee(assignment.getAssigneeIdentifier());
List<RoleAssignmentRow> assignments = roleAssigneeMap.get(ra);
if (assignments == null) {
assignments = new ArrayList();
assignments = new ArrayList<>();
roleAssigneeMap.put(ra, assignments);
}

Expand Down Expand Up @@ -266,8 +266,8 @@ private void revokeRole(Long roleAssignmentId) {
grant access dialog
*/
private List<RoleAssignee> selectedRoleAssignees;
private List<DataFile> selectedFiles = new ArrayList();
private final List<RoleAssignee> roleAssigneeList = new ArrayList();
private List<DataFile> selectedFiles = new ArrayList<>();
private final List<RoleAssignee> roleAssigneeList = new ArrayList<>();
private AuthenticatedUser fileRequester;

public List<RoleAssignee> getSelectedRoleAssignees() {
Expand Down Expand Up @@ -325,7 +325,7 @@ public List<RoleAssignee> completeRoleAssignee(String query) {
roleAssigneeList.addAll( explicitGroupService.findAvailableFor(dataset) );

}
List<RoleAssignee> returnList = new ArrayList();
List<RoleAssignee> returnList = new ArrayList<>();
for (RoleAssignee ra : roleAssigneeList) {
// @todo unsure if containsIgnore case will work for all locales
if ((StringUtils.containsIgnoreCase(ra.getDisplayInfo().getTitle(), query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public List<DataverseRole> getRoles() {
if (dvObject != null && dvObject.getId() != null) {
return roleService.findByOwnerId(dvObject.getId());
}
return new ArrayList();
return new ArrayList<>();
}

public void createNewRole(ActionEvent e) {
Expand Down Expand Up @@ -332,7 +332,7 @@ public List<RoleAssignee> completeRoleAssignee( String query ) {
}
roleAssigneeList.addAll( explicitGroupService.findAvailableFor(dvObject) );

List<RoleAssignee> filteredList = new LinkedList();
List<RoleAssignee> filteredList = new LinkedList<>();
for (RoleAssignee ra : roleAssigneeList) {
// @todo unsure if containsIgnore case will work for all locales
// @todo maybe add some solr/lucene style searching, did-you-mean style?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public void updatePermissionRoot(javax.faces.event.AjaxBehaviorEvent event) thro
private RoleAssignee assignRoleRoleAssignee; // used if input accepts a RoleAssignee through a converter
private Long assignRoleRoleId;

private final List<String> identifierList = new ArrayList();
private final List<String> identifierList = new ArrayList<>();

public List<String> completeIdentifier(String query) {
if (identifierList.isEmpty()) {
for (AuthenticatedUser au : authenticationService.findAllAuthenticatedUsers()) {
identifierList.add(au.getIdentifier());
}
}
List<String> returnList = new ArrayList();
List<String> returnList = new ArrayList<>();
for (String identifier : identifierList) {
if (identifier.contains(query)) {
returnList.add(identifier);
Expand All @@ -123,15 +123,15 @@ public List<String> completeIdentifier(String query) {
return returnList;
}

private final List<RoleAssignee> roleAssigneeList = new ArrayList();
private final List<RoleAssignee> roleAssigneeList = new ArrayList<>();

public List<RoleAssignee> completeRoleAssignee(String query) {
if (roleAssigneeList.isEmpty()) {
for (AuthenticatedUser au : authenticationService.findAllAuthenticatedUsers()) {
roleAssigneeList.add(au);
}
}
List<RoleAssignee> returnList = new ArrayList();
List<RoleAssignee> returnList = new ArrayList<>();
for (RoleAssignee ra : roleAssigneeList) {
// @todo unsure if containsIgnore case will work for all locales
if (StringUtils.containsIgnoreCase(ra.getDisplayInfo().getTitle(),query)) {
Expand Down Expand Up @@ -279,7 +279,7 @@ public List<DataverseRole> getRoles() {
if (dvObject != null) {
return roleService.findByOwnerId(dvObject.getId());
}
return new ArrayList();
return new ArrayList<>();
}

public void createNewRole(ActionEvent e) {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/edu/harvard/iq/dataverse/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ public void setTermsOfUseAndAccess(TermsOfUseAndAccess termsOfUseAndAccess) {

@OneToMany(mappedBy = "template", orphanRemoval = true, cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
//@OrderBy("datasetField.displayOrder")
private List<DatasetField> datasetFields = new ArrayList();
private List<DatasetField> datasetFields = new ArrayList<>();

public List<DatasetField> getDatasetFields() {
return datasetFields;
}

@Transient
private Map<MetadataBlock, List<DatasetField>> metadataBlocksForView = new HashMap();
private Map<MetadataBlock, List<DatasetField>> metadataBlocksForView = new HashMap<>();
@Transient
private Map<MetadataBlock, List<DatasetField>> metadataBlocksForEdit = new HashMap();
private Map<MetadataBlock, List<DatasetField>> metadataBlocksForEdit = new HashMap<>();

@Transient
private boolean isDefaultForDataverse;
Expand Down Expand Up @@ -172,7 +172,7 @@ public void setDataverse(Dataverse dataverse) {

private List<DatasetField> initDatasetFields() {
//retList - Return List of values
List<DatasetField> retList = new ArrayList();
List<DatasetField> retList = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {
retList.add(initDatasetField(dsf));
}
Expand Down Expand Up @@ -226,8 +226,8 @@ private void initMetadataBlocksForCreate() {
metadataBlocksForView.clear();
metadataBlocksForEdit.clear();
for (MetadataBlock mdb : this.getDataverse().getMetadataBlocks()) {
List<DatasetField> datasetFieldsForView = new ArrayList();
List<DatasetField> datasetFieldsForEdit = new ArrayList();
List<DatasetField> datasetFieldsForView = new ArrayList<>();
List<DatasetField> datasetFieldsForEdit = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {

if (dsf.getDatasetFieldType().getMetadataBlock().equals(mdb)) {
Expand All @@ -251,7 +251,7 @@ public void setMetadataValueBlocks() {
List<DatasetField> filledInFields = this.getDatasetFields();


List <MetadataBlock> actualMDB = new ArrayList();
List <MetadataBlock> actualMDB = new ArrayList<>();

actualMDB.addAll(this.getDataverse().getMetadataBlocks());
for (DatasetField dsfv : filledInFields) {
Expand All @@ -264,8 +264,8 @@ public void setMetadataValueBlocks() {
}

for (MetadataBlock mdb : actualMDB) {
List<DatasetField> datasetFieldsForView = new ArrayList();
List<DatasetField> datasetFieldsForEdit = new ArrayList();
List<DatasetField> datasetFieldsForView = new ArrayList<>();
List<DatasetField> datasetFieldsForEdit = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {
if (dsf.getDatasetFieldType().getMetadataBlock().equals(mdb)) {
datasetFieldsForEdit.add(dsf);
Expand Down Expand Up @@ -330,7 +330,7 @@ public Template cloneNewTemplate(Template source) {
}

public List<DatasetField> copyDatasetFields(List<DatasetField> copyFromList) {
List<DatasetField> retList = new ArrayList();
List<DatasetField> retList = new ArrayList<>();

for (DatasetField sourceDsf : copyFromList) {
//the copy needs to have the current version
Expand All @@ -352,7 +352,7 @@ public List<DatasetField> getFlatDatasetFields() {
}

private List<DatasetField> getFlatDatasetFields(List<DatasetField> dsfList) {
List<DatasetField> retList = new LinkedList();
List<DatasetField> retList = new LinkedList<>();
for (DatasetField dsf : dsfList) {
retList.add(dsf);
if (dsf.getDatasetFieldType().isCompound()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/TemplatePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public String save(String redirectPage) {
return "";
}
boolean create = false;
Command cmd;
Command<Void> cmd;
Long createdId = new Long(0);
Template created;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public String getSolrSchema() {
sb.append(" <field name=\"" + nameSearchable + "\" type=\"" + type + "\" multiValued=\"" + multivalued + "\" stored=\"true\" indexed=\"true\"/>\n");
}

List<String> listOfStaticFields = new ArrayList();
List<String> listOfStaticFields = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bencomp you're certainly right that this is a type safety issue but the default settings from Netbeans apparently don't provide developers the typical yellow warning indicators:

screen shot 2015-09-25 at 9 35 47 am

If you could please share the Netbeans settings you are using, I'd appreciate it. You could even add it to the Google Doc linked from http://guides.dataverse.org/en/latest/developers/coding-style.html

Object searchFieldsObject = new SearchFields();
Field[] staticSearchFields = searchFieldsObject.getClass().getDeclaredFields();
for (Field fieldObject : staticSearchFields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DataFileDTO {
private String UNF;
private String md5;
private String description;
private List<DataTableDTO> dataTables = new ArrayList();
private List<DataTableDTO> dataTables = new ArrayList<>();

public List<DataTableDTO> getDataTables() {
return dataTables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ private void loadRolesByDvObjectTable(){

// Row 1: Row Names
row.add("");
for (Map.Entry pair : roleNameSet) {
row.add("<b>" + (String)pair.getValue() + "</b> (" + pair.getKey() + ")");
for (Map.Entry<Long,String> pair : roleNameSet) {
row.add("<b>" + pair.getValue() + "</b> (" + pair.getKey() + ")");
}
this.rolesByDvObjectTable.add(row);

// Row 2: Dataverse role settings
//
row = new ArrayList<>();
row.add("<b>Dataverse</b>");
for (Map.Entry pair : roleNameSet) {
Long role_id = (Long)pair.getKey();
for (Map.Entry<Long,String> pair : roleNameSet) {
Long role_id = pair.getKey();
if (this.hasDataversePermissions(role_id)){
row.add("YES");
}else{
Expand All @@ -121,8 +121,8 @@ private void loadRolesByDvObjectTable(){
row = new ArrayList<>();
row.add("<b>Dataset</b>");

for (Map.Entry pair : roleNameSet) {
Long role_id = (Long)pair.getKey();
for (Map.Entry<Long,String> pair : roleNameSet) {
Long role_id = pair.getKey();
if (this.hasDatasetPermissions(role_id)){
row.add("YES");
}else{
Expand All @@ -135,8 +135,8 @@ private void loadRolesByDvObjectTable(){
//
row = new ArrayList<>();
row.add("<b>File</b>");
for (Map.Entry pair : roleNameSet) {
Long role_id = (Long)pair.getKey();
for (Map.Entry<Long,String> pair : roleNameSet) {
Long role_id = pair.getKey();
if (this.hasFilePermissions(role_id)){
row.add("YES");
}else{
Expand Down Expand Up @@ -241,20 +241,20 @@ public List<Entry<Long, String>> getRoleNamesAsArrayList(){

public List<String[]> getRoleInfoForCheckboxes(){

List<String[]> roleInfoList = new ArrayList<String[]>();
List<String[]> roleInfoList = new ArrayList<>();

for (Entry entry : roleNameLookup.entrySet()){
String idName = ((String)entry.getValue()).toLowerCase().replace(" + ", "").replace(" ", "");
for (Entry<Long,String> entry : roleNameLookup.entrySet()){
String idName = entry.getValue().toLowerCase().replace(" + ", "").replace(" ", "");
// triplet: key, name, id_name
// Examples: { 1, Admin, admin }, {2, File Downloader, filedownloader}
String[] singleRole = { ((Long)entry.getKey()).toString(), (String)entry.getValue(), idName };
String[] singleRole = { entry.getKey().toString(), entry.getValue(), idName };
roleInfoList.add(singleRole);
}
return roleInfoList;
}

private void msg(String s){
System.out.println(s);
logger.info(s);
}

private void msgt(String s){
Expand All @@ -267,8 +267,8 @@ private void msgt(String s){
public List<Long> getRoleIdList(){

List<Long> outputList = new ArrayList<>();
for (Map.Entry pair : roleNameLookup.entrySet()) {
outputList.add((Long)pair.getKey());
for (Map.Entry<Long,String> pair : roleNameLookup.entrySet()) {
outputList.add(pair.getKey());
}
return outputList;
}
Expand All @@ -277,7 +277,7 @@ public List<Long> getRoleIdList(){
public String getRoleNameListString(){
List<String> outputList = new ArrayList<>();

for (Map.Entry pair : roleNameLookup.entrySet()) {
for (Map.Entry<Long,String> pair : roleNameLookup.entrySet()) {
outputList.add(pair.getKey() + " --> " + pair.getValue());
}
return StringUtils.join(outputList, "<br />");
Expand All @@ -287,7 +287,7 @@ public String getRoleNameListString(){
public String getRolesWithDataversePermissionsAsHTML(){

List<String> outputList = new ArrayList<>();
for (Map.Entry pair : rolesWithDataversePermissions.entrySet()) {
for (Map.Entry<Long,Boolean> pair : rolesWithDataversePermissions.entrySet()) {
String roleName = this.roleNameLookup.get(pair.getKey());
outputList.add(roleName);
}
Expand All @@ -297,7 +297,7 @@ public String getRolesWithDataversePermissionsAsHTML(){
public String getDatasetRolesAsHTML(){

List<String> outputList = new ArrayList<>();
for (Map.Entry pair : this.rolesWithDatasetPermissions.entrySet()) {
for (Map.Entry<Long,Boolean> pair : this.rolesWithDatasetPermissions.entrySet()) {
String roleName = this.roleNameLookup.get(pair.getKey());
outputList.add(roleName);
}
Expand All @@ -307,7 +307,7 @@ public String getDatasetRolesAsHTML(){
public String getRolesWithFilePermissionsAsHTML(){

List<String> outputList = new ArrayList<>();
for (Map.Entry pair : this.rolesWithFilePermissions.entrySet()) {
for (Map.Entry<Long,Boolean> pair : this.rolesWithFilePermissions.entrySet()) {
String roleName = this.roleNameLookup.get(pair.getKey());
outputList.add(roleName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String getHumanName() {
}

public boolean appliesTo(Class<? extends DvObject> aClass) {
for (Class c : appliesTo) {
for (Class<? extends DvObject> c : appliesTo) {
if (c.isAssignableFrom(aClass)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean isEditable() {
}

@Override
public GroupProvider getGroupProvider() {
public GroupProvider<ShibGroup> getGroupProvider() {
return shibGroupProvider;
}

Expand Down
Loading