コード例 #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);
 }