at.molindo.utils.collections.BusinessKeyHashMap 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.HashMap;
import java.util.Iterator;
public class BusinessKeyHashMap> extends HashMap implements IBusinessKeyMap {
private static final long serialVersionUID = 1L;
private transient IBusinessKeySet _valueSet;
public static > BusinessKeyHashMap newMap(Class cls) {
return new BusinessKeyHashMap();
}
public static > BusinessKeyHashMap newMap(Iterable c) {
BusinessKeyHashMap map = newMap();
map.putAll(c);
return map;
}
public static > BusinessKeyHashMap newMap() {
return new BusinessKeyHashMap();
}
@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();
}
}