@@ -205,14 +205,16 @@ record = this.readNode(buffer, record, bit);
205205 * separately. To disable skipAliasedNetworks, which iterates over the IPv4 networks
206206 * only once, use the SkipAliasedNetworks parameter.
207207 *
208+ * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
209+ * @param typeParameterClass The type of data returned by the iterator.
208210 * @return Networks The Networks iterator.
209211 * @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
210212 * @throws ClosedDatabaseException Exception for a closed databased.
211213 * @throws InvalidDatabaseException Exception for an invalid database.
212214 */
213- public Networks networks () throws
215+ public < T > Networks < T > networks (Class < T > typeParameterClass ) throws
214216 InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
215- return this .networks (true );
217+ return this .networks (true , typeParameterClass );
216218 }
217219
218220 /**
@@ -222,13 +224,16 @@ public Networks networks() throws
222224 * separately. To set the iteration over the IPv4 networks once, use the
223225 * SkipAliasedNetworks option.
224226 *
227+ * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
225228 * @param skipAliasedNetworks Enable or disable skipping aliased networks.
226229 * @return Networks The Networks iterator.
227230 * @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
228231 * @throws ClosedDatabaseException Exception for a closed databased.
229232 * @throws InvalidDatabaseException Exception for an invalid database.
230233 */
231- public Networks networks (boolean skipAliasedNetworks ) throws
234+ public <T > Networks <T > networks (
235+ boolean skipAliasedNetworks ,
236+ Class <T > typeParameterClass ) throws
232237 InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
233238 try {
234239 InetAddress ipv4 = InetAddress .getByAddress (new byte [4 ]);
@@ -237,9 +242,9 @@ public Networks networks(boolean skipAliasedNetworks) throws
237242 Network ipAllV6 = new Network (ipv6 , 0 ); // Mask 128.
238243
239244 if (this .getMetadata ().getIpVersion () == 6 ) {
240- return this .networksWithin (ipAllV6 , skipAliasedNetworks );
245+ return this .networksWithin (ipAllV6 , skipAliasedNetworks , typeParameterClass );
241246 }
242- return this .networksWithin (ipAllV4 , skipAliasedNetworks );
247+ return this .networksWithin (ipAllV4 , skipAliasedNetworks , typeParameterClass );
243248 } catch (UnknownHostException e ) {
244249 /* This is returned by getByAddress. This should never happen
245250 as the ipv4 and ipv6 are constants set by us. */
@@ -288,12 +293,16 @@ private int findIpV4StartNode(ByteBuffer buffer)
288293 * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
289294 * @param network Specifies the network to be iterated.
290295 * @param skipAliasedNetworks Boolean for skipping aliased networks.
296+ * @param typeParameterClass The type of data returned by the iterator.
291297 * @return Networks
292298 * @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
293299 * @throws ClosedDatabaseException Exception for a closed databased.
294300 * @throws InvalidDatabaseException Exception for an invalid database.
295301 */
296- public <T > Networks <T > networksWithin (Network network , boolean skipAliasedNetworks )
302+ public <T > Networks <T > networksWithin (
303+ Network network ,
304+ boolean skipAliasedNetworks ,
305+ Class <T > typeParameterClass )
297306 throws InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
298307 InetAddress networkAddress = network .getNetworkAddress ();
299308 if (this .metadata .getIpVersion () == 4 && networkAddress instanceof Inet6Address ) {
@@ -321,7 +330,8 @@ public <T> Networks<T> networksWithin(Network network, boolean skipAliasedNetwor
321330 int prefix = traverseResult [1 ];
322331
323332 Networks <T > networks = new Networks <T >(this , skipAliasedNetworks ,
324- new Networks .NetworkNode []{ new Networks .NetworkNode (ipBytes , prefix , node ) });
333+ new Networks .NetworkNode []{new Networks .NetworkNode (ipBytes , prefix , node )},
334+ typeParameterClass );
325335
326336 return networks ;
327337 }
0 commit comments