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.renderer;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.jet.lang.resolve.name.FqName;
021    
022    import java.util.Collection;
023    import java.util.Collections;
024    
025    public class DescriptorRendererBuilder {
026        private boolean shortNames = false;
027        private boolean withDefinedIn = true;
028        private boolean modifiers = true;
029        private boolean startFromName = false;
030        private boolean debugMode = false;
031        private boolean classWithPrimaryConstructor = false;
032        private boolean verbose = false;
033        private boolean unitReturnType = true;
034        private boolean normalizedVisibilities = false;
035        private boolean showInternalKeyword = true;
036        @NotNull
037        private DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy = DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN;
038        @NotNull
039        private DescriptorRenderer.ValueParametersHandler valueParametersHandler = new DescriptorRenderer.DefaultValueParameterHandler();
040        @NotNull
041        private DescriptorRenderer.TextFormat textFormat = DescriptorRenderer.TextFormat.PLAIN;
042        @NotNull
043        private Collection<FqName> excludedAnnotationClasses = Collections.emptyList();
044    
045        public DescriptorRendererBuilder() {
046        }
047    
048        public DescriptorRendererBuilder setShortNames(boolean shortNames) {
049            this.shortNames = shortNames;
050            return this;
051        }
052    
053        public DescriptorRendererBuilder setWithDefinedIn(boolean withDefinedIn) {
054            this.withDefinedIn = withDefinedIn;
055            return this;
056        }
057    
058        public DescriptorRendererBuilder setModifiers(boolean modifiers) {
059            this.modifiers = modifiers;
060            return this;
061        }
062    
063        public DescriptorRendererBuilder setStartFromName(boolean startFromName) {
064            this.startFromName = startFromName;
065            return this;
066        }
067    
068        public DescriptorRendererBuilder setDebugMode(boolean debugMode) {
069            this.debugMode = debugMode;
070            return this;
071        }
072    
073        public DescriptorRendererBuilder setClassWithPrimaryConstructor(boolean classWithPrimaryConstructor) {
074            this.classWithPrimaryConstructor = classWithPrimaryConstructor;
075            return this;
076        }
077    
078        public DescriptorRendererBuilder setVerbose(boolean verbose) {
079            this.verbose = verbose;
080            return this;
081        }
082    
083        public DescriptorRendererBuilder setUnitReturnType(boolean unitReturnType) {
084            this.unitReturnType = unitReturnType;
085            return this;
086        }
087    
088        public DescriptorRendererBuilder setNormalizedVisibilities(boolean normalizedVisibilities) {
089            this.normalizedVisibilities = normalizedVisibilities;
090            return this;
091        }
092    
093        public DescriptorRendererBuilder setShowInternalKeyword(boolean showInternalKeyword) {
094            this.showInternalKeyword = showInternalKeyword;
095            return this;
096        }
097    
098        public DescriptorRendererBuilder setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy) {
099            this.overrideRenderingPolicy = overrideRenderingPolicy;
100            return this;
101        }
102    
103        public DescriptorRendererBuilder setValueParametersHandler(@NotNull DescriptorRenderer.ValueParametersHandler valueParametersHandler) {
104            this.valueParametersHandler = valueParametersHandler;
105            return this;
106        }
107    
108        public DescriptorRendererBuilder setTextFormat(@NotNull DescriptorRenderer.TextFormat textFormat) {
109            this.textFormat = textFormat;
110            return this;
111        }
112    
113        public DescriptorRendererBuilder setExcludedAnnotationClasses(@NotNull Collection<FqName> excludedAnnotationClasses) {
114            this.excludedAnnotationClasses = excludedAnnotationClasses;
115            return this;
116        }
117    
118        public DescriptorRenderer build() {
119            return new DescriptorRendererImpl(shortNames, withDefinedIn, modifiers, startFromName, debugMode, classWithPrimaryConstructor,
120                                              verbose, unitReturnType, normalizedVisibilities, showInternalKeyword, overrideRenderingPolicy,
121                                              valueParametersHandler, textFormat, excludedAnnotationClasses);
122        }
123    
124    }