001    /*
002     * Copyright 2010-2014 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.jet.codegen;
018    
019    import com.intellij.psi.PsiElement;
020    import org.jetbrains.annotations.NotNull;
021    import org.jetbrains.annotations.Nullable;
022    import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
023    import org.jetbrains.org.objectweb.asm.ClassVisitor;
024    import org.jetbrains.org.objectweb.asm.FieldVisitor;
025    import org.jetbrains.org.objectweb.asm.MethodVisitor;
026    
027    public abstract class DelegatingClassBuilder implements ClassBuilder {
028        @NotNull
029        protected abstract ClassBuilder getDelegate();
030    
031        @NotNull
032        @Override
033        public FieldVisitor newField(
034                @Nullable PsiElement origin,
035                int access,
036                @NotNull String name,
037                @NotNull String desc,
038                @Nullable String signature,
039                @Nullable Object value
040        ) {
041            return getDelegate().newField(origin, access, name, desc, signature, value);
042        }
043    
044        @NotNull
045        @Override
046        public MethodVisitor newMethod(
047                @Nullable PsiElement origin,
048                int access,
049                @NotNull String name,
050                @NotNull String desc,
051                @Nullable String signature,
052                @Nullable String[] exceptions
053        ) {
054            return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
055        }
056    
057        @NotNull
058        @Override
059        public JvmSerializationBindings getSerializationBindings() {
060            return getDelegate().getSerializationBindings();
061        }
062    
063        @NotNull
064        @Override
065        public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
066            return getDelegate().newAnnotation(desc, visible);
067        }
068    
069        @Override
070        public void done() {
071            getDelegate().done();
072        }
073    
074        @NotNull
075        @Override
076        public ClassVisitor getVisitor() {
077            return getDelegate().getVisitor();
078        }
079    
080        @Override
081        public void defineClass(
082                @Nullable PsiElement origin,
083                int version,
084                int access,
085                @NotNull String name,
086                @Nullable String signature,
087                @NotNull String superName,
088                @NotNull String[] interfaces
089        ) {
090            getDelegate().defineClass(origin, version, access, name, signature, superName, interfaces);
091        }
092    
093        @Override
094        public void visitSource(@NotNull String name, @Nullable String debug) {
095            getDelegate().visitSource(name, debug);
096        }
097    
098        @Override
099        public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
100            getDelegate().visitOuterClass(owner, name, desc);
101        }
102    
103        @Override
104        public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
105            getDelegate().visitInnerClass(name, outerName, innerName, access);
106        }
107    
108        @NotNull
109        @Override
110        public String getThisName() {
111            return getDelegate().getThisName();
112        }
113    }