예제 #1
0
파일: IaAddress.java 프로젝트: jstuyts/dhcp
 public DhcpOption getDhcpOption(int code) {
   DhcpOption result = null;
   if (dhcpOptions != null) {
     Iterator<DhcpOption> iterator = dhcpOptions.iterator();
     while (result == null && iterator.hasNext()) {
       DhcpOption dhcpOption = iterator.next();
       if (dhcpOption.getCode() == code) {
         result = dhcpOption;
       }
     }
   }
   return result;
 }
예제 #2
0
파일: IaAddress.java 프로젝트: jstuyts/dhcp
 public void setDhcpOption(DhcpOption newOption) {
   if (dhcpOptions == null) {
     dhcpOptions = new ArrayList<>();
   }
   // first remove the option, if it exists
   boolean hasNotBeenRemoved = true;
   Iterator<DhcpOption> dhcpOptionsIterator = dhcpOptions.iterator();
   while (hasNotBeenRemoved && dhcpOptionsIterator.hasNext()) {
     DhcpOption dhcpOption = dhcpOptionsIterator.next();
     if (dhcpOption.getCode() == newOption.getCode()) {
       dhcpOptionsIterator.remove();
       hasNotBeenRemoved = false;
     }
   }
   dhcpOptions.add(newOption);
 }