org.cometd.oort.OortLongMap Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2021 the original author or authors.
*
* 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 org.cometd.oort;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
/**
* The equivalent of an {@code OortMap<Long,V>}.
*
* @param the value type
*/
public class OortLongMap extends OortMap {
public OortLongMap(Oort oort, String name, Factory> factory) {
super(oort, name, factory);
}
@Override
protected Object deserialize(Object object) {
// Convert keys from String (as they were created by JSON libraries)
// to Long as required by the key type of this class.
@SuppressWarnings("unchecked")
Map map = (Map)object;
if (map.isEmpty()) {
return object;
}
Map result = new HashMap<>(map.size());
for (Map.Entry entry : map.entrySet()) {
result.put(Long.parseLong(entry.getKey()), entry.getValue());
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy