@Deprecated // in 2.9.4 -- must call method that takes old and new property to avoid mismatch public void replace(SettableBeanProperty newProp) { String key = getPropertyName(newProp); int ix = _findIndexInHash(key); if (ix < 0) { throw new NoSuchElementException("No entry '"+key+"' found, can't replace"); } SettableBeanProperty prop = (SettableBeanProperty) _hashArea[ix]; _hashArea[ix] = newProp; // also, replace in in-order _propsInOrder[_findFromOrdered(prop)] = newProp; }
String key = getPropertyName(prop); int slot = _hashCode(key); int ix = (slot<<1);
String key = getPropertyName(propToRm); boolean found = false;
/** * 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. */ public BeanPropertyMap withProperty(SettableBeanProperty newProp) { // First: may be able to just replace? String key = getPropertyName(newProp); for (int i = 1, end = _hashArea.length; i < end; i += 2) { SettableBeanProperty prop = (SettableBeanProperty) _hashArea[i]; if ((prop != null) && prop.getName().equals(key)) { return new BeanPropertyMap(this, newProp, i, _findFromOrdered(prop)); } } // If not, append final int slot = _hashCode(key); return new BeanPropertyMap(this, newProp, key, slot); }
@Deprecated // in 2.9.4 -- must call method that takes old and new property to avoid mismatch public void replace(SettableBeanProperty newProp) { String key = getPropertyName(newProp); int ix = _findIndexInHash(key); if (ix < 0) { throw new NoSuchElementException("No entry '"+key+"' found, can't replace"); } SettableBeanProperty prop = (SettableBeanProperty) _hashArea[ix]; _hashArea[ix] = newProp; // also, replace in in-order _propsInOrder[_findFromOrdered(prop)] = newProp; }
/** * Specialized method for removing specified existing entry. * NOTE: entry MUST exist, otherwise an exception is thrown. */ public void remove(SettableBeanProperty property) { // Mostly this is the same as code with 'replace', just bit simpler... String name = getPropertyName(property); int index = name.hashCode() & (_buckets.length-1); Bucket tail = null; boolean found = false; // slightly complex just because chain is immutable, must recreate for (Bucket bucket = _buckets[index]; bucket != null; bucket = bucket.next) { // match to remove? if (!found && bucket.key.equals(name)) { found = true; } else { tail = new Bucket(tail, bucket.key, bucket.value, bucket.index); } } if (!found) { // must be found throw new NoSuchElementException("No entry '"+property+"' found, can't remove"); } _buckets[index] = tail; }
public BeanPropertyMap(Collection<SettableBeanProperty> properties, boolean caseInsensitivePropertyComparison) { _caseInsensitive = caseInsensitivePropertyComparison; _size = properties.size(); int bucketCount = findSize(_size); _hashMask = bucketCount-1; Bucket[] buckets = new Bucket[bucketCount]; for (SettableBeanProperty property : properties) { String key = getPropertyName(property); int index = key.hashCode() & _hashMask; buckets[index] = new Bucket(buckets[index], key, property, _nextBucketIndex++); } _buckets = buckets; }
/** * Specialized method for removing specified existing entry. * NOTE: entry MUST exist, otherwise an exception is thrown. */ public void remove(SettableBeanProperty property) { // Mostly this is the same as code with 'replace', just bit simpler... String name = getPropertyName(property); int index = name.hashCode() & (_buckets.length-1); Bucket tail = null; boolean found = false; // slightly complex just because chain is immutable, must recreate for (Bucket bucket = _buckets[index]; bucket != null; bucket = bucket.next) { // match to remove? if (!found && bucket.key.equals(name)) { found = true; } else { tail = new Bucket(tail, bucket.key, bucket.value, bucket.index); } } if (!found) { // must be found throw new NoSuchElementException("No entry '"+property+"' found, can't remove"); } _buckets[index] = tail; }
public BeanPropertyMap(Collection<SettableBeanProperty> properties, boolean caseInsensitivePropertyComparison) { _caseInsensitive = caseInsensitivePropertyComparison; _size = properties.size(); int bucketCount = findSize(_size); _hashMask = bucketCount-1; Bucket[] buckets = new Bucket[bucketCount]; for (SettableBeanProperty property : properties) { String key = getPropertyName(property); int index = key.hashCode() & _hashMask; buckets[index] = new Bucket(buckets[index], key, property, _nextBucketIndex++); } _buckets = buckets; }
/** * Specialized method that can be used to replace an existing entry * (note: entry MUST exist; otherwise exception is thrown) with * specified replacement. */ public void replace(SettableBeanProperty newProp) { String key = getPropertyName(newProp); int ix = _findIndexInHash(key); if (ix >= 0) { SettableBeanProperty prop = (SettableBeanProperty) _hashArea[ix]; _hashArea[ix] = newProp; // also, replace in in-order _propsInOrder[_findFromOrdered(prop)] = newProp; return; } throw new NoSuchElementException("No entry '"+key+"' found, can't replace"); }
String name = getPropertyName(property); int index = name.hashCode() & (_buckets.length-1);
String name = getPropertyName(property); int index = name.hashCode() & (_buckets.length-1);
String key = getPropertyName(propToRm); boolean found = false;
String key = getPropertyName(propToRm); boolean found = false;
String key = getPropertyName(prop); int slot = _hashCode(key); int ix = (slot<<1);
String key = getPropertyName(prop); int slot = _hashCode(key); int ix = (slot<<1);
String key = getPropertyName(newProp);
Bucket[] newBuckets = new Bucket[bcount]; System.arraycopy(_buckets, 0, newBuckets, 0, bcount); final String propName = getPropertyName(newProperty);
Bucket[] newBuckets = new Bucket[bcount]; System.arraycopy(_buckets, 0, newBuckets, 0, bcount); final String propName = getPropertyName(newProperty);
/** * 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. */ public BeanPropertyMap withProperty(SettableBeanProperty newProp) { // First: may be able to just replace? String key = getPropertyName(newProp); for (int i = 1, end = _hashArea.length; i < end; i += 2) { SettableBeanProperty prop = (SettableBeanProperty) _hashArea[i]; if ((prop != null) && prop.getName().equals(key)) { return new BeanPropertyMap(this, newProp, i, _findFromOrdered(prop)); } } // If not, append final int slot = _hashCode(key); return new BeanPropertyMap(this, newProp, key, slot); }