/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with this
 * work for additional information regarding copyright ownership. The ASF
 * licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.apache.sling.jcr.resource.internal;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;

/**
 * Decorated resource which prepends the workspace name to
 * a delegate resource's path.
 */
class WorkspaceDecoratedResource implements Resource {

    private final Resource delegate;
    private final String workspaceName;

    WorkspaceDecoratedResource(Resource resource, String workspaceName) {
        this.delegate = resource;
        this.workspaceName = workspaceName;
    }

    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        return delegate.adaptTo(type);
    }

    public String getPath() {
        if (workspaceName != null) {
            return workspaceName + ":" + delegate.getPath();
        } else {
            return delegate.getPath();
        }
    }

    public ResourceMetadata getResourceMetadata() {
        return delegate.getResourceMetadata();
    }

    public ResourceResolver getResourceResolver() {
        return delegate.getResourceResolver();
    }

    public String getResourceSuperType() {
        return delegate.getResourceSuperType();
    }

    public String getResourceType() {
        return delegate.getResourceType();
    }

    public String toString() {
        return delegate.toString();
    }

}

@@ -934,69 +934,13 @@
 urce
-Metadata;%0Aimport org.apache.sling.api.resource.ResourceResolv
+Wrapp
 er;%0A
@@ -1075,17 +1075,14 @@
 rce 
-implement
+extend
 s Re
@@ -1091,48 +1091,18 @@
 urce
- %7B%0A%0A    private final Resource delegate;
+Wrapper %7B%0A
 %0A   
@@ -1225,32 +1225,22 @@
     
-this.delegate = 
+super(
 resource
 ;%0A  
@@ -1235,16 +1235,17 @@
 resource
+)
 ;%0A      
@@ -1304,786 +1304,168 @@
 lic 
-%3CAdapterType%3E AdapterType adaptTo(Class%3CAdapterType%3E type) %7B%0A        return delegate.adaptTo(type);%0A    %7D%0A%0A    public String getPath() %7B%0A        if (workspaceName != null) %7B%0A            return workspaceName + %22:%22 + delegate.getPath();%0A        %7D else %7B%0A            return delegate.getPath();%0A        %7D%0A    %7D%0A%0A    public ResourceMetadata getResourceMetadata() %7B%0A        return delegate.getResourceMetadata();%0A    %7D%0A%0A    public ResourceResolver getResourceResolver() %7B%0A        return delegate.getResourceResolver();%0A    %7D%0A%0A    public String getResourceSuperType() %7B%0A        return delegate.getResourceSuperType();%0A    %7D%0A%0A    public String getResourceType() %7B%0A        return delegate.getResourceType();%0A    %7D%0A%0A    public String toString() %7B%0A        return delegate.toString();%0A    %7D%0A
+String getPath() %7B%0A        if (workspaceName != null) %7B%0A            return workspaceName + %22:%22 + super.getPath();%0A        %7D%0A        return super.getPath();%0A    %7D
 %0A%7D%0A

Clean up code and use resource wrapper