001    /*
002     * Copyright 2010-2015 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.codegen;
018    
019    import com.intellij.psi.PsiElement;
020    import org.jetbrains.annotations.NotNull;
021    import org.jetbrains.annotations.Nullable;
022    import org.jetbrains.kotlin.codegen.inline.FileMapping;
023    import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
024    import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
025    import org.jetbrains.org.objectweb.asm.ClassVisitor;
026    import org.jetbrains.org.objectweb.asm.FieldVisitor;
027    import org.jetbrains.org.objectweb.asm.MethodVisitor;
028    
029    public abstract class DelegatingClassBuilder implements ClassBuilder {
030        @NotNull
031        protected abstract ClassBuilder getDelegate();
032    
033        @NotNull
034        @Override
035        public FieldVisitor newField(
036                @NotNull JvmDeclarationOrigin origin,
037                int access,
038                @NotNull String name,
039                @NotNull String desc,
040                @Nullable String signature,
041                @Nullable Object value
042        ) {
043            return getDelegate().newField(origin, access, name, desc, signature, value);
044        }
045    
046        @NotNull
047        @Override
048        public MethodVisitor newMethod(
049                @NotNull JvmDeclarationOrigin origin,
050                int access,
051                @NotNull String name,
052                @NotNull String desc,
053                @Nullable String signature,
054                @Nullable String[] exceptions
055        ) {
056            return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
057        }
058    
059        @NotNull
060        @Override
061        public JvmSerializationBindings getSerializationBindings() {
062            return getDelegate().getSerializationBindings();
063        }
064    
065        @NotNull
066        @Override
067        public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
068            return getDelegate().newAnnotation(desc, visible);
069        }
070    
071        @Override
072        public void done() {
073            getDelegate().done();
074        }
075    
076        @NotNull
077        @Override
078        public ClassVisitor getVisitor() {
079            return getDelegate().getVisitor();
080        }
081    
082        @Override
083        public void defineClass(
084                @Nullable PsiElement origin,
085                int version,
086                int access,
087                @NotNull String name,
088                @Nullable String signature,
089                @NotNull String superName,
090                @NotNull String[] interfaces
091        ) {
092            getDelegate().defineClass(origin, version, access, name, signature, superName, interfaces);
093        }
094    
095        @Override
096        public void visitSource(@NotNull String name, @Nullable String debug) {
097            getDelegate().visitSource(name, debug);
098        }
099    
100        @Override
101        public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
102            getDelegate().visitOuterClass(owner, name, desc);
103        }
104    
105        @Override
106        public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
107            getDelegate().visitInnerClass(name, outerName, innerName, access);
108        }
109    
110        @NotNull
111        @Override
112        public String getThisName() {
113            return getDelegate().getThisName();
114        }
115    
116        @Override
117        public void addSMAP(FileMapping mapping) {
118            getDelegate().addSMAP(mapping);
119        }
120    }