public static DeviceOracle createDeviceOracle(
      String macStr,
      Long vlan,
      String entityClassName,
      String ipStr,
      String dpidStr,
      Short switchPortNumber)
      throws BigDBException {
    if (macStr == null) {
      throw new BigDBException("Mac Address cannot be null.");
    }
    Short vlanShort = vlan == null ? null : Short.valueOf(vlan.shortValue());
    Integer port = switchPortNumber == null ? null : Integer.valueOf(switchPortNumber);
    Integer ipv4 = ipStr == null ? null : IPv4.toIPv4Address(ipStr);
    Long dpid = dpidStr == null ? null : HexString.toLong(dpidStr);
    IEntityClass entityClass =
        getDeviceService().getEntityClassifier().getEntityClassByName(entityClassName);
    if (entityClass == null) {
      throw new BigDBException(
          "Invalid entity class name, config the " + "entity class first: " + entityClassName);
    }
    Entity en = new Entity(HexString.toLong(macStr), vlanShort, ipv4, dpid, port, null);

    String deviceId = IndexedEntity.getKeyString(entityClassName, en, entityClass.getKeyFields());
    return new DeviceOracle(deviceId, macStr, vlanShort, entityClassName, ipStr, dpidStr, port);
  }
 public DeviceOracle(
     String deviceId,
     long mac,
     Short vlan,
     String entityClassName,
     Integer ipAddress,
     Long switchDPID,
     Integer switchPortNumber)
     throws BigDBException {
   if (deviceId == null) {
     throw new BigDBException("Device ID cannot be null.");
   }
   String ip = ipAddress == null ? null : IPv4.fromIPv4Address(ipAddress);
   String dpid = switchDPID == null ? null : HexString.toHexString(switchDPID, 8);
   String macStr = HexString.toHexString(mac, 6);
   this.deviceId = deviceId;
   this.mac = macStr;
   this.vlan = vlan;
   this.entityClassName = entityClassName;
   this.ipAddress = ip;
   this.switchDPID = dpid;
   this.switchPortNumber = switchPortNumber;
 }
 @Override
 public void serialize(Integer ip, DataNodeGenerator generator) throws BigDBException {
   generator.writeString(ip == null ? "" : IPv4.fromIPv4Address(ip));
 }