Skip to content

Commit

Permalink
Merge pull request Azure#1122 from martinsawicki/compute-2017-03-netw…
Browse files Browse the repository at this point in the history
…ork-2017-08-regen

Tweaking Subnet.listNetworkInterfaceIPCOnfigurations()
  • Loading branch information
Martin Sawicki authored Sep 11, 2017
2 parents bc93c03 + dcd9350 commit 59d0022
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package com.microsoft.azure.management.network;

import java.util.Collection;
import java.util.Set;

import com.microsoft.azure.management.apigeneration.Beta;
Expand Down Expand Up @@ -42,7 +43,7 @@ public interface Subnet extends
* Note that this call may result in multiple calls to Azure to fetch all the referenced interfaces each time it is invoked.
*/
@Method
Set<NicIPConfiguration> listNetworkInterfaceIPConfigurations();
Collection<NicIPConfiguration> listNetworkInterfaceIPConfigurations();

/**
* @return available private IP addresses within this network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
*/
package com.microsoft.azure.management.network.implementation;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import com.microsoft.azure.SubResource;
Expand Down Expand Up @@ -140,13 +141,13 @@ public NetworkSecurityGroup getNetworkSecurityGroup() {

@Override
public Set<NicIPConfiguration> getNetworkInterfaceIPConfigurations() {
return listNetworkInterfaceIPConfigurations();
return Collections.unmodifiableSet(new TreeSet<NicIPConfiguration>(listNetworkInterfaceIPConfigurations()));
}

@Override
public Set<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
Set<NicIPConfiguration> ipConfigs = new HashSet<>();
Map<String, NetworkInterface> nics = new HashMap<>();
public Collection<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
Collection<NicIPConfiguration> ipConfigs = new ArrayList<>();
Map<String, NetworkInterface> nics = new TreeMap<>();
List<IPConfigurationInner> ipConfigRefs = this.inner().ipConfigurations();
if (ipConfigRefs == null) {
return ipConfigs;
Expand Down Expand Up @@ -180,7 +181,7 @@ public Set<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
ipConfigs.add(ipConfig);
}

return Collections.unmodifiableSet(ipConfigs);
return Collections.unmodifiableCollection(ipConfigs);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
package com.microsoft.azure.management;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.junit.Assert;

Expand Down Expand Up @@ -58,7 +58,7 @@ public NetworkInterface createResource(NetworkInterfaces networkInterfaces) thro
Subnet subnet = network.subnets().get(ipConfig.subnetName());
Assert.assertNotNull(subnet);
Assert.assertEquals(1, subnet.networkInterfaceIPConfigurationCount());
Set<NicIPConfiguration> ipConfigs = subnet.listNetworkInterfaceIPConfigurations();
Collection<NicIPConfiguration> ipConfigs = subnet.listNetworkInterfaceIPConfigurations();
Assert.assertNotNull(ipConfigs);
Assert.assertEquals(1, ipConfigs.size());
NicIPConfiguration ipConfig2 = null;
Expand Down

0 comments on commit 59d0022

Please sign in to comment.