Skip to content

Commit

Permalink
refactor: Fix unchecked type conversions (#4095)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyxell authored Aug 16, 2021
1 parent 244407c commit 9a45639
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/spoon/ContractVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public void checkParentConsistency() {
public void checkParentConsistency(CtElement element) {
final Set<CtElement> inconsistentParents = new HashSet<>();
new CtScanner() {
private Deque<CtElement> previous = new ArrayDeque();
private Deque<CtElement> previous = new ArrayDeque<>();

@Override
protected void enter(CtElement e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public List<?> getMatchedTargets(TobeMatched tobeMatchedTargets) {
if (nrOfMatches == 0) {
return Collections.emptyList();
}
List<Object> matched = new ArrayList(nrOfMatches);
List<Object> matched = new ArrayList<>(nrOfMatches);
for (Object target : getTargets()) {
if (containsSame(tobeMatchedTargets.getTargets(), target)) {
//this origin target is still available in this to be matched targets
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/reflect/visitor/ImportCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ private static String getImportRefID(CtReference ref) {
*/
private boolean removeAllTypeImportWithPackage(Set<CtImport> imports, String packageName) {
boolean found = false;
for (Iterator iter = imports.iterator(); iter.hasNext();) {
CtImport newImport = (CtImport) iter.next();
for (Iterator<CtImport> iter = imports.iterator(); iter.hasNext();) {
CtImport newImport = iter.next();
if (newImport.getImportKind() == CtImportKind.TYPE) {
CtTypeReference<?> typeRef = (CtTypeReference<?>) newImport.getReference();
if (typeRef.getPackage() != null && packageName.equals(typeRef.getPackage().getQualifiedName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public Map<String, CtExpression> getValues() {

@Override
public Map<String, CtExpression> getAllValues() {
Map<String, CtExpression> values = new TreeMap();
Map<String, CtExpression> values = new TreeMap<>();
// first, we put the default values
CtAnnotationType<?> annotationType = (CtAnnotationType) getAnnotationType().getTypeDeclaration();
for (CtAnnotationMethod m : annotationType.getAnnotationMethods()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public Map<String, Object> getAllMetadata() {
@Override
public Set<String> getMetadataKeys() {
if (metadata == null) {
return Collections.EMPTY_SET;
return Collections.emptySet();
}
return metadata.keySet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ChangeResolver {
public ChangeResolver(ChangeCollector changeCollector, CtElement element) {
this.changeCollector = changeCollector;
this.element = element;
changedRoles = element != null ? changeCollector.getChanges(element) : Collections.EMPTY_SET;
changedRoles = element != null ? changeCollector.getChanges(element) : Collections.emptySet();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ private boolean isSameSignatureLikeScopeMethod(CtExecutable<?> thatExecutable, b
if (actualTA instanceof CtWildcardReference) {
CtWildcardReference wildcardReference = (CtWildcardReference) actualTA;
if (wildcardReference.isDefaultBoundingType()) {
thatType.setActualTypeArguments(Collections.EMPTY_LIST);
thatType.setActualTypeArguments(Collections.emptyList());
}
}
}
Expand Down

0 comments on commit 9a45639

Please sign in to comment.