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.ResourceSearchResult; 035import org.sonar.wsclient.services.Review; 036import org.sonar.wsclient.services.Rule; 037import org.sonar.wsclient.services.Server; 038import org.sonar.wsclient.services.ServerSetup; 039import org.sonar.wsclient.services.Source; 040import org.sonar.wsclient.services.TimeMachine; 041import org.sonar.wsclient.services.Violation; 042 043import java.util.HashMap; 044import java.util.Map; 045 046public final class Unmarshallers { 047 private Unmarshallers() { 048 } 049 050 private static Map<Class, Unmarshaller> unmarshallers; 051 052 static { 053 unmarshallers = new HashMap<Class, Unmarshaller>(); 054 unmarshallers.put(Metric.class, new MetricUnmarshaller()); 055 unmarshallers.put(Dependency.class, new DependencyUnmarshaller()); 056 unmarshallers.put(Resource.class, new ResourceUnmarshaller()); 057 unmarshallers.put(Property.class, new PropertyUnmarshaller()); 058 unmarshallers.put(Source.class, new SourceUnmarshaller()); 059 unmarshallers.put(Violation.class, new ViolationUnmarshaller()); 060 unmarshallers.put(Server.class, new ServerUnmarshaller()); 061 unmarshallers.put(ServerSetup.class, new ServerSetupUnmarshaller()); 062 unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller()); 063 unmarshallers.put(Event.class, new EventUnmarshaller()); 064 unmarshallers.put(Favourite.class, new FavouriteUnmarshaller()); 065 unmarshallers.put(Plugin.class, new PluginUnmarshaller()); 066 unmarshallers.put(Rule.class, new RuleUnmarshaller()); 067 unmarshallers.put(TimeMachine.class, new TimeMachineUnmarshaller()); 068 unmarshallers.put(Profile.class, new ProfileUnmarshaller()); 069 unmarshallers.put(Review.class, new ReviewUnmarshaller()); 070 unmarshallers.put(ManualMeasure.class, new ManualMeasureUnmarshaller()); 071 unmarshallers.put(Authentication.class, new AuthenticationUnmarshaller()); 072 unmarshallers.put(ResourceSearchResult.class, new ResourceSearchUnmarshaller()); 073 } 074 075 public static <M extends Model> Unmarshaller<M> forModel(Class<M> modelClass) { 076 return unmarshallers.get(modelClass); 077 } 078}