2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.infra.distro.activation;
19 import com.google.inject.Module;
22 import java.util.stream.Collectors;
24 import static java.lang.String.format;
27 * Provides static set of active activeModulesClasses
29 public class ActiveModules {
30 private final Set<Class<? extends Module>> activeModulesClasses;
32 public ActiveModules(final Set<Class<? extends Module>> activeModulesClasses) {
33 this.activeModulesClasses = activeModulesClasses;
36 public Set<Class<? extends Module>> getActiveModulesClasses() {
37 return activeModulesClasses;
40 public Set<? extends Module> createModuleInstances() {
41 return activeModulesClasses.stream()
44 return moduleClass.newInstance();
45 } catch (InstantiationException | IllegalAccessException e) {
46 throw new IllegalStateException(format("Unable to create instance of module %s", moduleClass),
49 }).collect(Collectors.toSet());
53 public String toString() {
54 return "ActiveModules{" +
55 "activeModulesClasses=" + activeModulesClasses +