Code example for AtomicReference

Methods: get

0
      this.groupCreator = checkNotNull(groupCreator, "groupCreator");
   } 
 
   @Override 
   public SecurityGroupInZone load(ZoneAndName in) {
      AtomicReference<ZoneAndName> securityGroupInZoneRef = new AtomicReference<ZoneAndName>(checkNotNull(in,
               "zoneSecurityGroupNameAndPorts")); 
      if (returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef)) {
         return returnExistingSecurityGroup(securityGroupInZoneRef);
      } else { 
         return createNewSecurityGroup(in);
      } 
   } 
 
   private SecurityGroupInZone returnExistingSecurityGroup(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
      ZoneAndName securityGroupInZone = securityGroupInZoneRef.get();
      checkState(securityGroupInZone instanceof SecurityGroupInZone,
               "programming error: predicate %s should update the atomic reference to the actual security group found", 
               returnSecurityGroupExistsInZone);
      return SecurityGroupInZone.class.cast(securityGroupInZone);
   }