limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 1 | /** |
| 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 | |
| 17 | package com.google.inject; |
| 18 | |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 19 | import com.google.inject.internal.Errors; |
limpbizkit | 53664a7 | 2009-02-21 00:25:27 +0000 | [diff] [blame] | 20 | import com.google.inject.internal.Lists; |
limpbizkit | c3f9284 | 2008-12-30 19:43:47 +0000 | [diff] [blame] | 21 | import com.google.inject.spi.PrivateElements; |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 22 | import java.util.List; |
| 23 | |
| 24 | /** |
| 25 | * Handles {@link Binder#newPrivateBinder()} elements. |
| 26 | * |
| 27 | * @author jessewilson@google.com (Jesse Wilson) |
| 28 | */ |
limpbizkit | c3f9284 | 2008-12-30 19:43:47 +0000 | [diff] [blame] | 29 | class PrivateElementProcessor extends AbstractProcessor { |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 30 | |
| 31 | private final Stage stage; |
| 32 | private final List<InjectorShell.Builder> injectorShellBuilders = Lists.newArrayList(); |
| 33 | |
limpbizkit | c3f9284 | 2008-12-30 19:43:47 +0000 | [diff] [blame] | 34 | PrivateElementProcessor(Errors errors, Stage stage) { |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 35 | super(errors); |
| 36 | this.stage = stage; |
| 37 | } |
| 38 | |
limpbizkit | 03b81a6 | 2009-03-18 05:34:39 +0000 | [diff] [blame^] | 39 | @Override public Boolean visit(PrivateElements privateElements) { |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 40 | InjectorShell.Builder builder = new InjectorShell.Builder() |
| 41 | .parent(injector) |
| 42 | .stage(stage) |
limpbizkit | c3f9284 | 2008-12-30 19:43:47 +0000 | [diff] [blame] | 43 | .privateElements(privateElements); |
limpbizkit | fcbdf99 | 2008-11-26 02:37:35 +0000 | [diff] [blame] | 44 | injectorShellBuilders.add(builder); |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | public List<InjectorShell.Builder> getInjectorShellBuilders() { |
| 49 | return injectorShellBuilders; |
| 50 | } |
| 51 | } |