Line data Source code
1 : // Copyright (C) 2019 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.plugins; 16 : 17 : import com.google.common.annotations.VisibleForTesting; 18 : import com.google.common.collect.ImmutableSet; 19 : import com.google.common.collect.Sets; 20 : import com.google.gerrit.server.config.GerritServerConfig; 21 : import com.google.inject.Inject; 22 : import com.google.inject.Singleton; 23 : import java.util.Arrays; 24 : import java.util.Set; 25 : import java.util.concurrent.CopyOnWriteArraySet; 26 : import org.eclipse.jgit.lib.Config; 27 : 28 : @Singleton 29 : public class MandatoryPluginsCollection { 30 : private final CopyOnWriteArraySet<String> members; 31 : 32 : @Inject 33 149 : MandatoryPluginsCollection(@GerritServerConfig Config cfg) { 34 149 : members = Sets.newCopyOnWriteArraySet(); 35 149 : members.addAll(Arrays.asList(cfg.getStringList("plugins", null, "mandatory"))); 36 149 : } 37 : 38 : public boolean contains(String name) { 39 2 : return members.contains(name); 40 : } 41 : 42 : public Set<String> asSet() { 43 138 : return ImmutableSet.copyOf(members); 44 : } 45 : 46 : @VisibleForTesting 47 : public void add(String name) { 48 1 : members.add(name); 49 1 : } 50 : }