001/** 002 * Copyright 2013 John Ericksen 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.androidtransfuse.model; 017 018import org.androidtransfuse.adapter.ASTType; 019import org.androidtransfuse.adapter.PackageClass; 020import org.androidtransfuse.gen.componentBuilder.ExpressionVariableDependentGenerator; 021import org.androidtransfuse.gen.componentBuilder.InjectionNodeFactory; 022import org.androidtransfuse.gen.componentBuilder.MethodBuilder; 023 024import java.util.ArrayList; 025import java.util.Arrays; 026import java.util.Collection; 027import java.util.List; 028 029/** 030 * @author John Ericksen 031 */ 032public class ComponentDescriptor { 033 034 private final PackageClass packageClass; 035 private final String type; 036 private MethodBuilder initMethodBuilder; 037 private List<ExpressionVariableDependentGenerator> generators = new ArrayList<ExpressionVariableDependentGenerator>(); 038 private List<ExpressionVariableDependentGenerator> registrations = new ArrayList<ExpressionVariableDependentGenerator>(); 039 private InjectionNodeFactory injectionNodeFactory; 040 private ASTType initMethodEventAnnotation; 041 042 public ComponentDescriptor(String type, PackageClass packageClass) { 043 this.type = type; 044 this.packageClass = packageClass; 045 } 046 047 public PackageClass getPackageClass() { 048 return packageClass; 049 } 050 051 public String getType() { 052 return type; 053 } 054 055 public MethodBuilder getInitMethodBuilder() { 056 return initMethodBuilder; 057 } 058 059 public List<ExpressionVariableDependentGenerator> getGenerators() { 060 return generators; 061 } 062 063 public void addGenerators(Collection<ExpressionVariableDependentGenerator> generators) { 064 this.generators.addAll(generators); 065 } 066 067 public void addGenerators(ExpressionVariableDependentGenerator... generators) { 068 if (generators != null) { 069 addGenerators(Arrays.asList(generators)); 070 } 071 } 072 073 public void setInitMethodBuilder(ASTType initEventAnnotation, MethodBuilder initMethodBuilder) { 074 this.initMethodBuilder = initMethodBuilder; 075 this.initMethodEventAnnotation = initEventAnnotation; 076 } 077 078 public InjectionNodeFactory getInjectionNodeFactory() { 079 return injectionNodeFactory; 080 } 081 082 public void setInjectionNodeFactory(InjectionNodeFactory injectionNodeFactory) { 083 this.injectionNodeFactory = injectionNodeFactory; 084 } 085 086 public ASTType getInitMethodEventAnnotation() { 087 return initMethodEventAnnotation; 088 } 089 090 public List<ExpressionVariableDependentGenerator> getRegistrations() { 091 return registrations; 092 } 093 094 public void addRegistration(ExpressionVariableDependentGenerator generator){ 095 registrations.add(generator); 096 } 097}