Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
package com.fasterxml.jackson.databind.deser.impl;
import java.util.*;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.SettableBeanProperty;
import com.fasterxml.jackson.databind.util.NameTransformer;
/**
* Helper class used for storing mapping from property name to
* {@link SettableBeanProperty} instances.
*
* Note that this class is used instead of generic {@link java.util.HashMap}
* for bit of performance gain (and some memory savings): although default
* implementation is very good for generic use cases, it can be streamlined
* a bit for specific use case we have. Even relatively small improvements
* matter since this is directly on the critical path during deserialization,
* as it is done for each and every POJO property deserialized.
*/
public final class BeanPropertyMap
implements Iterable,
java.io.Serializable // since 2.1
{
private static final long serialVersionUID = 1L;
private final Bucket[] _buckets;
private final int _hashMask;
private final int _size;
/**
* Counter we use to keep track of insertion order of properties
* (to be able to recreate insertion order when needed).
*
* Note: is kept up-to-date with additions, but can NOT handle
* removals (i.e. "holes" may be left)
*/
private int _nextBucketIndex = 0;
public BeanPropertyMap(Collection properties)
{
_size = properties.size();
int bucketCount = findSize(_size);
_hashMask = bucketCount-1;
Bucket[] buckets = new Bucket[bucketCount];
for (SettableBeanProperty property : properties) {
String key = property.getName();
int index = key.hashCode() & _hashMask;
buckets[index] = new Bucket(buckets[index], key, property, _nextBucketIndex++);
}
_buckets = buckets;
}
private BeanPropertyMap(Bucket[] buckets, int size, int index)
{
_buckets = buckets;
_size = size;
_hashMask = buckets.length-1;
_nextBucketIndex = index;
}
/**
* Fluent copy method that creates a new instance that is a copy
* of this instance except for one additional property that is
* passed as the argument.
* Note that method does not modify this instance but constructs
* and returns a new one.
*
* @since 2.0
*/
public BeanPropertyMap withProperty(SettableBeanProperty newProperty)
{
// first things first: can just copy hash area:
final int bcount = _buckets.length;
Bucket[] newBuckets = new Bucket[bcount];
System.arraycopy(_buckets, 0, newBuckets, 0, bcount);
final String propName = newProperty.getName();
// and then see if it's add or replace:
SettableBeanProperty oldProp = find(newProperty.getName());
if (oldProp == null) { // add
// first things first: add or replace?
// can do a straight copy, since all additions are at the front
// and then insert the new property:
int index = propName.hashCode() & _hashMask;
newBuckets[index] = new Bucket(newBuckets[index],
propName, newProperty, _nextBucketIndex++);
return new BeanPropertyMap(newBuckets, _size+1, _nextBucketIndex);
}
// replace: easy, close + replace
BeanPropertyMap newMap = new BeanPropertyMap(newBuckets, bcount, _nextBucketIndex);
newMap.replace(newProperty);
return newMap;
}
/**
* Factory method for constructing a map where all entries use given
* prefix
*/
public BeanPropertyMap renameAll(NameTransformer transformer)
{
if (transformer == null || (transformer == NameTransformer.NOP)) {
return this;
}
Iterator it = iterator();
ArrayList newProps = new ArrayList();
while (it.hasNext()) {
SettableBeanProperty prop = it.next();
String newName = transformer.transform(prop.getName());
prop = prop.withSimpleName(newName);
JsonDeserializer> deser = prop.getValueDeserializer();
if (deser != null) {
@SuppressWarnings("unchecked")
JsonDeserializer