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