Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb731e2

Browse files
committedOct 17, 2024
Refactore PGPSignatureSubpacketVector
1 parent c34c9d3 commit bb731e2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎pg/src/main/java/org/bouncycastle/openpgp/PGPSignatureSubpacketVector.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public boolean hasSubpacket(
116116
public SignatureSubpacket[] getSubpackets(
117117
int type)
118118
{
119-
List list = new ArrayList();
119+
List<SignatureSubpacket> list = new ArrayList<>();
120120

121121
for (int i = 0; i != packets.length; i++)
122122
{
@@ -126,28 +126,28 @@ public SignatureSubpacket[] getSubpackets(
126126
}
127127
}
128128

129-
return (SignatureSubpacket[])list.toArray(new SignatureSubpacket[]{});
129+
return list.toArray(new SignatureSubpacket[0]);
130130
}
131131

132132
public PGPSignatureList getEmbeddedSignatures()
133133
throws PGPException
134134
{
135135
SignatureSubpacket[] sigs = getSubpackets(SignatureSubpacketTags.EMBEDDED_SIGNATURE);
136-
ArrayList l = new ArrayList();
136+
ArrayList<PGPSignature> l = new ArrayList<>();
137137

138-
for (int i = 0; i < sigs.length; i++)
138+
for (SignatureSubpacket sig : sigs)
139139
{
140140
try
141141
{
142-
l.add(new PGPSignature(SignaturePacket.fromByteArray(sigs[i].getData())));
142+
l.add(new PGPSignature(SignaturePacket.fromByteArray(sig.getData())));
143143
}
144144
catch (IOException e)
145145
{
146146
throw new PGPException("Unable to parse signature packet: " + e.getMessage(), e);
147147
}
148148
}
149149

150-
return new PGPSignatureList((PGPSignature[])l.toArray(new PGPSignature[l.size()]));
150+
return new PGPSignatureList(l.toArray(new PGPSignature[0]));
151151
}
152152

153153
public NotationData[] getNotationDataOccurrences()
@@ -179,7 +179,7 @@ public NotationData[] getNotationDataOccurences()
179179
public NotationData[] getNotationDataOccurrences(String notationName)
180180
{
181181
NotationData[] notations = getNotationDataOccurrences();
182-
List<NotationData> notationsWithName = new ArrayList<NotationData>();
182+
List<NotationData> notationsWithName = new ArrayList<>();
183183
for (int i = 0; i != notations.length; i++)
184184
{
185185
NotationData notation = notations[i];
@@ -188,7 +188,7 @@ public NotationData[] getNotationDataOccurrences(String notationName)
188188
notationsWithName.add(notation);
189189
}
190190
}
191-
return (NotationData[])notationsWithName.toArray(new NotationData[0]);
191+
return notationsWithName.toArray(new NotationData[0]);
192192
}
193193

194194
public long getIssuerKeyID()

0 commit comments

Comments
 (0)
Please sign in to comment.