jetbrains.coverage.report.impl.html.MapToSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of coverage-report Show documentation
Show all versions of coverage-report Show documentation
HTML coverage report generator
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jetbrains.coverage.report.impl.html;
import org.jetbrains.annotations.NotNull;
import java.util.*;
/**
* @author Eugene Petrenko ([email protected])
* 13.10.10 17:44
*/
public class MapToSet {
private final Map> myMap = new HashMap>();
public void addValue(K k, @NotNull V v) {
Collection vs = myMap.get(k);
if (vs == null) {
myMap.put(k, vs = new HashSet());
}
vs.add(v);
}
public boolean isEmpty() {
return myMap.isEmpty();
}
@NotNull
public Collection getValues(K k) {
final Collection vs = myMap.get(k);
return vs == null ? Collections.emptyList() : Collections.unmodifiableCollection(vs);
}
@NotNull
public Collection keySet() {
return Collections.unmodifiableCollection(myMap.keySet());
}
}