@Mapping(from = QosBase.class, to = QoS.class) public static QoS map(QosBase entity, QoS template) { QoS model = template != null ? template : new QoS(); model.setId(entity.getId().toString()); model.setName(entity.getName()); model.setType( org.ovirt.engine.api.model.QosType.fromValue(entity.getQosType().toString()) .name() .toLowerCase()); model.setDataCenter(new DataCenter()); model.getDataCenter().setId(entity.getStoragePoolId().toString()); model.setDescription(entity.getDescription()); switch (entity.getQosType()) { case STORAGE: StorageQos storageQos = null; // avoid findbugs error. if (entity instanceof StorageQos) { storageQos = (StorageQos) entity; } // avoid findbugs error. if (storageQos == null) { return model; } model.setMaxThroughput(storageQos.getMaxThroughput()); model.setMaxReadThroughput(storageQos.getMaxReadThroughput()); model.setMaxWriteThroughput(storageQos.getMaxWriteThroughput()); model.setMaxIops(storageQos.getMaxIops()); model.setMaxReadIops(storageQos.getMaxReadIops()); model.setMaxWriteIops(storageQos.getMaxWriteIops()); break; case CPU: CpuQos cpuQos = null; // avoid findbugs error. if (entity instanceof CpuQos) { cpuQos = (CpuQos) entity; } // avoid findbugs error. if (cpuQos == null) { return model; } model.setCpuLimit(cpuQos.getCpuLimit()); break; case NETWORK: NetworkQoS networkQos = null; // avoid findbugs error. if (entity instanceof NetworkQoS) { networkQos = (NetworkQoS) entity; } // avoid findbugs error. if (networkQos == null) { return model; } model.setInboundAverage(networkQos.getInboundAverage()); model.setInboundPeak(networkQos.getInboundPeak()); model.setInboundBurst(networkQos.getInboundBurst()); model.setOutboundAverage(networkQos.getOutboundAverage()); model.setOutboundPeak(networkQos.getOutboundPeak()); model.setOutboundBurst(networkQos.getOutboundBurst()); break; default: break; } return model; }