001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program 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 * This program 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 License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.measures; 021 022import java.util.Map; 023import java.util.TreeMap; 024import org.sonar.api.utils.KeyValueFormat; 025 026/** 027 * @since 1.10 028 * @deprecated since 5.6. Use directly {@link KeyValueFormat}. 029 */ 030@Deprecated 031public class PropertiesBuilder<K, V> { 032 private Metric metric; 033 private Map<K, V> props; 034 035 public PropertiesBuilder(Metric metric, Map<K, V> map) { 036 this.props = new TreeMap<>(map); 037 this.metric = metric; 038 } 039 040 public PropertiesBuilder(Metric metric) { 041 this.props = new TreeMap<>(); 042 this.metric = metric; 043 } 044 045 public PropertiesBuilder() { 046 this.props = new TreeMap<>(); 047 } 048 049 public PropertiesBuilder<K, V> clear() { 050 this.props.clear(); 051 return this; 052 } 053 054 public Map<K, V> getProps() { 055 return props; 056 } 057 058 public Metric getMetric() { 059 return metric; 060 } 061 062 public PropertiesBuilder<K, V> setMetric(Metric metric) { 063 this.metric = metric; 064 return this; 065 } 066 067 public PropertiesBuilder<K, V> add(K key, V value) { 068 props.put(key, value); 069 return this; 070 } 071 072 public PropertiesBuilder<K, V> addAll(Map<K, V> map) { 073 props.putAll(map); 074 return this; 075 } 076 077 public Measure build() { 078 return new Measure(metric, buildData()); 079 } 080 081 public String buildData() { 082 return KeyValueFormat.format(props); 083 } 084}