// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolverService.java
// public class DeviceTypeResolverService {
// 
//     private List<DeviceTypeResolver> typeResolvers;
// 
//     public DeviceTypeResolverService() {
//         typeResolvers = new ArrayList<>();
//         typeResolvers.add(new LedStripTypeResolver());
//     }
// 
//     public void addTypeResolver(DeviceTypeResolver r) {
//         typeResolvers.add(r);
//     }
// 
//     public DeviceTypeResolver get(String name) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.getClass().getSimpleName().equals(name)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// 
//     public DeviceTypeResolver get(NsdServiceInfo info) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.supports(info)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// 
//     public DeviceTypeResolver get(SsdpService info) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.supports(info)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// }


import com.loicortola.controller.device.DeviceTypeResolverService;
import java.util.ArrayList;
import java.util.List;
package com.loicortola.controller.persistence;



/**
 * Created by loic on 28/03/2016.
 */
public class DeviceMapper {

    private DeviceTypeResolverService resolverService;

    public DeviceMapper() {

    }

    public DeviceMapper(DeviceTypeResolverService rs) {
        this.resolverService = rs;
    }

    public com.loicortola.controller.model.Device map(Device d) {
        if (d == null) {
            return null;
        }
        return com.loicortola.controller.model.Device.builder()
                .dbId(d.getId())
                .id(d.getDeviceId())
                .icon((int) d.getIcon())
                .name(d.getName())
                .host(d.getHost())
                .key(d.getKey())
                .resolver(resolverService.get(d.getDeviceResolver()))
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolverService.java
// public class DeviceTypeResolverService {
// 
//     private List<DeviceTypeResolver> typeResolvers;
// 
//     public DeviceTypeResolverService() {
//         typeResolvers = new ArrayList<>();
//         typeResolvers.add(new LedStripTypeResolver());
//     }
// 
//     public void addTypeResolver(DeviceTypeResolver r) {
//         typeResolvers.add(r);
//     }
// 
//     public DeviceTypeResolver get(String name) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.getClass().getSimpleName().equals(name)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// 
//     public DeviceTypeResolver get(NsdServiceInfo info) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.supports(info)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// 
//     public DeviceTypeResolver get(SsdpService info) {
//         for (DeviceTypeResolver r : typeResolvers) {
//             if (r.supports(info)) {
//                 return r;
//             }
//         }
//         return null;
//     }
// }


// Path: android/app/src/main/java/com/loicortola/controller/persistence/DeviceMapper.java
import com.loicortola.controller.device.DeviceTypeResolverService;
import java.util.ArrayList;
import java.util.List;

package com.loicortola.controller.persistence;



/**
 * Created by loic on 28/03/2016.
 */
public class DeviceMapper {

    private DeviceTypeResolverService resolverService;

    public DeviceMapper() {

    }

    public DeviceMapper(DeviceTypeResolverService rs) {
        this.resolverService = rs;
    }

    public com.loicortola.controller.model.Device map(Device d) {
        if (d == null) {
            return null;
        }
        return com.loicortola.controller.model.Device.builder()
                .dbId(d.getId())
                .id(d.getDeviceId())
                .icon((int) d.getIcon())
                .name(d.getName())
                .host(d.getHost())
                .key(d.getKey())
                .resolver(resolverService.get(d.getDeviceResolver()))
                .build();