blob: a767b9f4505a04ab3d44710c65f5567c13e7175f [file] [log] [blame]
limpbizkitfcbdf992008-11-26 02:37:35 +00001/**
2 * Copyright (C) 2008 Google Inc.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.google.inject;
18
limpbizkitfcbdf992008-11-26 02:37:35 +000019import com.google.inject.internal.Errors;
limpbizkit53664a72009-02-21 00:25:27 +000020import com.google.inject.internal.Lists;
limpbizkitc3f92842008-12-30 19:43:47 +000021import com.google.inject.spi.PrivateElements;
limpbizkitfcbdf992008-11-26 02:37:35 +000022import java.util.List;
23
24/**
25 * Handles {@link Binder#newPrivateBinder()} elements.
26 *
27 * @author jessewilson@google.com (Jesse Wilson)
28 */
limpbizkitc3f92842008-12-30 19:43:47 +000029class PrivateElementProcessor extends AbstractProcessor {
limpbizkitfcbdf992008-11-26 02:37:35 +000030
31 private final Stage stage;
32 private final List<InjectorShell.Builder> injectorShellBuilders = Lists.newArrayList();
33
limpbizkitc3f92842008-12-30 19:43:47 +000034 PrivateElementProcessor(Errors errors, Stage stage) {
limpbizkitfcbdf992008-11-26 02:37:35 +000035 super(errors);
36 this.stage = stage;
37 }
38
limpbizkit03b81a62009-03-18 05:34:39 +000039 @Override public Boolean visit(PrivateElements privateElements) {
limpbizkitfcbdf992008-11-26 02:37:35 +000040 InjectorShell.Builder builder = new InjectorShell.Builder()
41 .parent(injector)
42 .stage(stage)
limpbizkitc3f92842008-12-30 19:43:47 +000043 .privateElements(privateElements);
limpbizkitfcbdf992008-11-26 02:37:35 +000044 injectorShellBuilders.add(builder);
45 return true;
46 }
47
48 public List<InjectorShell.Builder> getInjectorShellBuilders() {
49 return injectorShellBuilders;
50 }
51}