DeviceResource.java 1.61 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.api.resource.ModifiableValueMap
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.api.resource.SyntheticResource
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.cq.screens.impl.rest;

import com.adobe.cq.screens.device.Device;
import com.adobe.cq.screens.impl.rest.DeviceValueMapDecorator;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
import org.apache.sling.api.resource.ValueMap;

public class DeviceResource
extends SyntheticResource {
    public static final String RESOURCE_TYPE = "screens/core/components/device";
    private final Device device;

    public DeviceResource(ResourceResolver resolver, String path, Device device) {
        super(resolver, path, "screens/core/components/device");
        this.device = device;
    }

    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        if (type == ValueMap.class || type == ModifiableValueMap.class) {
            Resource profile = this.getResourceResolver().getResource(this.device.getPath() + "/" + "profile_screens");
            return (AdapterType)((Object)(profile == null ? null : new DeviceValueMapDecorator(this, (ValueMap)profile.adaptTo(type))));
        }
        if (type == Device.class) {
            return (AdapterType)this.device;
        }
        return (AdapterType)super.adaptTo(type);
    }
}