001package org.kohsuke.args4j.spi; 002 003import java.lang.reflect.Field; 004import java.util.List; 005import java.util.Map; 006 007/** 008 * Factory of {@link Setter}s. 009 * 010 * @author Kohsuke Kawaguchi 011 */ 012public class Getters { 013 014 /** 015 * 016 * @param name 017 * @param f 018 * @param bean 019 * @return estimate the type of field and return the appropriate getter 020 */ 021 public static Getter<?> create(String name, Field f, Object bean) { 022 if(List.class.isAssignableFrom(f.getType())) 023 return new MultiValueFieldGetter(name,bean,f); 024 else if(Map.class.isAssignableFrom(f.getType())) 025 return new MapGetter(name,bean,f); 026 else 027 return new FieldGetter(name,bean,f); 028 } 029}