@Test public void testGetAffinity() { PersistentDiskEntity disk = new PersistentDiskEntity(); disk.setAffinities(null); assertThat(disk.getAffinity("vm"), nullValue()); disk.setAffinities(new ArrayList<LocalityEntity>()); assertThat(disk.getAffinity("vm"), nullValue()); LocalityEntity localityEntity = new LocalityEntity(); localityEntity.setKind("vm"); localityEntity.setResourceId("vm-id1"); List<LocalityEntity> affinities = ImmutableList.of(localityEntity); disk.setAffinities(affinities); assertThat(disk.getAffinity("disk"), nullValue()); assertThat(disk.getAffinity("vm"), is("vm-id1")); }
public String getAffinity(String kind) { if (affinities == null) { return null; } for (LocalityEntity affinity : affinities) { if (java.util.Objects.equals(affinity.getKind(), kind)) { return affinity.getResourceId(); } } return null; }
PersistentDiskEntity extends BaseDiskEntity { public String getAffinity(String kind) { if (affinities == null) { return null; } for (LocalityEntity affinity : affinities) { if (java.util.Objects.equals(affinity.getKind(), kind)) { return affinity.getResourceId(); } } return null; } }
PersistentDiskEntity extends BaseDiskEntity { public String getAffinity(String kind) { if (affinities == null) { return null; } for (LocalityEntity affinity : affinities) { if (java.util.Objects.equals(affinity.getKind(), kind)) { return affinity.getResourceId(); } } return null; }  }
PersistentDiskEntity extends BaseDiskEntity { public String getAffinity(String kind) { if (affinities == null) { return null; } for (LocalityEntity affinity : affinities) { if (java.util.Objects.equals(affinity.getKind(), kind)) { return affinity.getResourceId(); } } return null; }  @Override String getKind(); List<LocalityEntity> getAffinities(); void setAffinities(List<LocalityEntity> affinities); List<String> getAffinities(String kind); String getAffinity(String kind); @Override String getAgent(); @Override void setAgent(String agent); }
PersistentDiskEntity extends BaseDiskEntity { public String getAffinity(String kind) { if (affinities == null) { return null; } for (LocalityEntity affinity : affinities) { if (java.util.Objects.equals(affinity.getKind(), kind)) { return affinity.getResourceId(); } } return null; }  @Override String getKind(); List<LocalityEntity> getAffinities(); void setAffinities(List<LocalityEntity> affinities); List<String> getAffinities(String kind); String getAffinity(String kind); @Override String getAgent(); @Override void setAgent(String agent);  }