at.molindo.utils.collections.BusinessKeyTreeMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molindo-utils Show documentation
Show all versions of molindo-utils Show documentation
Simply utility methods used across other Molindo projects
/**
* Copyright 2010 Molindo GmbH
*
* 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 at.molindo.utils.collections;
import java.util.Iterator;
import java.util.TreeMap;
public class BusinessKeyTreeMap> extends TreeMap implements IBusinessKeyMap {
private static final long serialVersionUID = 1L;
private transient IBusinessKeySet _valueSet;
public static > BusinessKeyTreeMap newMap(Class cls) {
return new BusinessKeyTreeMap();
}
public static > BusinessKeyTreeMap newMap(Iterable c) {
BusinessKeyTreeMap map = newMap();
map.putAll(c);
return map;
}
public static > BusinessKeyTreeMap newMap() {
return new BusinessKeyTreeMap();
}
@Override
public V put(V v) {
return put(v.getBusinessKey(), v);
}
@Override
public void putAll(Iterable c) {
for (V v : c) {
put(v);
}
}
@Override
public IBusinessKeySet valueSet() {
if (_valueSet == null) {
_valueSet = BusinessKeySet.newSet(this);
}
return _valueSet;
}
@Override
public Iterator iterator() {
return values().iterator();
}
}