001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020package org.sonar.wsclient.unmarshallers; 021 022import org.sonar.wsclient.services.Authentication; 023import org.sonar.wsclient.services.Dependency; 024import org.sonar.wsclient.services.DependencyTree; 025import org.sonar.wsclient.services.Event; 026import org.sonar.wsclient.services.Favourite; 027import org.sonar.wsclient.services.ManualMeasure; 028import org.sonar.wsclient.services.Metric; 029import org.sonar.wsclient.services.Model; 030import org.sonar.wsclient.services.Plugin; 031import org.sonar.wsclient.services.Profile; 032import org.sonar.wsclient.services.Property; 033import org.sonar.wsclient.services.Resource; 034import org.sonar.wsclient.services.Review; 035import org.sonar.wsclient.services.Rule; 036import org.sonar.wsclient.services.Server; 037import org.sonar.wsclient.services.ServerSetup; 038import org.sonar.wsclient.services.Source; 039import org.sonar.wsclient.services.TimeMachine; 040import org.sonar.wsclient.services.Violation; 041 042import java.util.HashMap; 043import java.util.Map; 044 045public final class Unmarshallers { 046 private Unmarshallers() { 047 } 048 049 private static Map<Class, Unmarshaller> unmarshallers; 050 051 static { 052 unmarshallers = new HashMap<Class, Unmarshaller>(); 053 unmarshallers.put(Metric.class, new MetricUnmarshaller()); 054 unmarshallers.put(Dependency.class, new DependencyUnmarshaller()); 055 unmarshallers.put(Resource.class, new ResourceUnmarshaller()); 056 unmarshallers.put(Property.class, new PropertyUnmarshaller()); 057 unmarshallers.put(Source.class, new SourceUnmarshaller()); 058 unmarshallers.put(Violation.class, new ViolationUnmarshaller()); 059 unmarshallers.put(Server.class, new ServerUnmarshaller()); 060 unmarshallers.put(ServerSetup.class, new ServerSetupUnmarshaller()); 061 unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller()); 062 unmarshallers.put(Event.class, new EventUnmarshaller()); 063 unmarshallers.put(Favourite.class, new FavouriteUnmarshaller()); 064 unmarshallers.put(Plugin.class, new PluginUnmarshaller()); 065 unmarshallers.put(Rule.class, new RuleUnmarshaller()); 066 unmarshallers.put(TimeMachine.class, new TimeMachineUnmarshaller()); 067 unmarshallers.put(Profile.class, new ProfileUnmarshaller()); 068 unmarshallers.put(Review.class, new ReviewUnmarshaller()); 069 unmarshallers.put(ManualMeasure.class, new ManualMeasureUnmarshaller()); 070 unmarshallers.put(Authentication.class, new AuthenticationUnmarshaller()); 071 } 072 073 public static <MODEL extends Model> Unmarshaller<MODEL> forModel(Class<MODEL> modelClass) { 074 return unmarshallers.get(modelClass); 075 } 076}