001    /*
002     * Copyright 2010-2013 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.descriptors.serialization.descriptors;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.jet.descriptors.serialization.NameResolver;
021    import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
022    import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
023    import org.jetbrains.jet.lang.descriptors.ClassOrPackageFragmentDescriptor;
024    import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
025    
026    import static org.jetbrains.jet.descriptors.serialization.descriptors.Deserializers.AnnotatedCallableKind;
027    
028    public interface AnnotationDeserializer {
029        AnnotationDeserializer UNSUPPORTED = new AnnotationDeserializer() {
030            @NotNull
031            @Override
032            public Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) {
033                return notSupported();
034            }
035    
036            @NotNull
037            @Override
038            public Annotations loadCallableAnnotations(
039                    @NotNull ClassOrPackageFragmentDescriptor container,
040                    @NotNull ProtoBuf.Callable proto,
041                    @NotNull NameResolver nameResolver,
042                    @NotNull AnnotatedCallableKind kind
043            ) {
044                return notSupported();
045            }
046    
047            @NotNull
048            @Override
049            public Annotations loadValueParameterAnnotations(
050                    @NotNull ClassOrPackageFragmentDescriptor container,
051                    @NotNull ProtoBuf.Callable callable,
052                    @NotNull NameResolver nameResolver,
053                    @NotNull AnnotatedCallableKind kind,
054                    @NotNull ProtoBuf.Callable.ValueParameter proto
055            ) {
056                return notSupported();
057            }
058    
059            @NotNull
060            private Annotations notSupported() {
061                throw new UnsupportedOperationException("Annotations are not supported");
062            }
063        };
064    
065        @NotNull
066        Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto);
067    
068        @NotNull
069        Annotations loadCallableAnnotations(
070                @NotNull ClassOrPackageFragmentDescriptor container,
071                @NotNull ProtoBuf.Callable proto,
072                @NotNull NameResolver nameResolver,
073                @NotNull AnnotatedCallableKind kind
074        );
075    
076        @NotNull
077        Annotations loadValueParameterAnnotations(
078                @NotNull ClassOrPackageFragmentDescriptor container,
079                @NotNull ProtoBuf.Callable callable,
080                @NotNull NameResolver nameResolver,
081                @NotNull AnnotatedCallableKind kind,
082                @NotNull ProtoBuf.Callable.ValueParameter proto
083        );
084    }