/** * @since 2.6 */ public static BeanPropertyMap construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String,List<PropertyName>> aliasMapping) { return new BeanPropertyMap(caseInsensitive, props, aliasMapping); }
/** * Mutant factory method that constructs a new instance if desired case-insensitivity * state differs from the state of this instance; if states are the same, returns * <code>this</code>. * * @since 2.8 */ public BeanPropertyMap withCaseInsensitivity(boolean state) { if (_caseInsensitive == state) { return this; } return new BeanPropertyMap(this, state); }
/** * Mutant factory method that will use this instance as the base, and * construct an instance that is otherwise same except for excluding * properties with specified names. * * @since 2.8 */ public BeanPropertyMap withoutProperties(Collection<String> toExclude) { if (toExclude.isEmpty()) { return this; } final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // 01-May-2015, tatu: Not 100% sure if existing `null`s should be retained; // or, if entries to ignore should be retained as nulls. For now just // prune them out if (prop != null) { // may contain holes, too, check. if (!toExclude.contains(prop.getName())) { newProps.add(prop); } } } // should we try to re-index? Apparently no need return new BeanPropertyMap(_caseInsensitive, newProps, _aliasDefs); }
/** * Mutant 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; } // Try to retain insertion ordering as well final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // What to do with holes? For now, retain if (prop == null) { newProps.add(prop); continue; } newProps.add(_rename(prop, transformer)); } // should we try to re-index? Ordering probably changed but caller probably doesn't want changes... // 26-Feb-2017, tatu: Probably SHOULD handle renaming wrt Aliases? return new BeanPropertyMap(_caseInsensitive, newProps, _aliasDefs); }
/** * 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); }
/** * @since 2.6 */ public static BeanPropertyMap construct(Collection<SettableBeanProperty> props, boolean caseInsensitive) { return new BeanPropertyMap(caseInsensitive, props); }
/** * @since 2.6 */ public static BeanPropertyMap construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String,List<PropertyName>> aliasMapping) { return new BeanPropertyMap(caseInsensitive, props, aliasMapping); }
/** * Mutant factory method that constructs a new instance if desired case-insensitivity * state differs from the state of this instance; if states are the same, returns * <code>this</code>. * * @since 2.8 */ public BeanPropertyMap withCaseInsensitivity(boolean state) { if (_caseInsensitive == state) { return this; } return new BeanPropertyMap(this, state); }
/** * Mutant factory method that constructs a new instance if desired case-insensitivity * state differs from the state of this instance; if states are the same, returns * <code>this</code>. * * @since 2.8 */ public BeanPropertyMap withCaseInsensitivity(boolean state) { if (_caseInsensitive == state) { return this; } return new BeanPropertyMap(this, state); }
/** * Mutant 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; } // Try to retain insertion ordering as well final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // What to do with holes? For now, retain if (prop == null) { newProps.add(prop); continue; } newProps.add(_rename(prop, transformer)); } // should we try to re-index? Ordering probably changed but caller probably doesn't want changes... return new BeanPropertyMap(_caseInsensitive, newProps); }
/** * Mutant 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; } // Try to retain insertion ordering as well final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // What to do with holes? For now, retain if (prop == null) { newProps.add(prop); continue; } newProps.add(_rename(prop, transformer)); } // should we try to re-index? Ordering probably changed but caller probably doesn't want changes... // 26-Feb-2017, tatu: Probably SHOULD handle renaming wrt Aliases? return new BeanPropertyMap(_caseInsensitive, newProps, _aliasDefs); }
/** * Mutant factory method that will use this instance as the base, and * construct an instance that is otherwise same except for excluding * properties with specified names. * * @since 2.8 */ public BeanPropertyMap withoutProperties(Collection<String> toExclude) { if (toExclude.isEmpty()) { return this; } final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // 01-May-2015, tatu: Not 100% sure if existing `null`s should be retained; // or, if entries to ignore should be retained as nulls. For now just // prune them out if (prop != null) { // may contain holes, too, check. if (!toExclude.contains(prop.getName())) { newProps.add(prop); } } } // should we try to re-index? Apparently no need return new BeanPropertyMap(_caseInsensitive, newProps, _aliasDefs); }
/** * Mutant factory method that will use this instance as the base, and * construct an instance that is otherwise same except for excluding * properties with specified names. * * @since 2.8 */ public BeanPropertyMap withoutProperties(Collection<String> toExclude) { if (toExclude.isEmpty()) { return this; } final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // 01-May-2015, tatu: Not 100% sure if existing `null`s should be retained; // or, if entries to ignore should be retained as nulls. For now just // prune them out if (prop != null) { // may contain holes, too, check. if (!toExclude.contains(prop.getName())) { newProps.add(prop); } } } // should we try to re-index? Apparently no need return new BeanPropertyMap(_caseInsensitive, newProps); }
/** * 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); }
newBuckets[index] = new Bucket(newBuckets[index], propName, newProperty, _nextBucketIndex++); return new BeanPropertyMap(newBuckets, _size+1, _nextBucketIndex, _caseInsensitive); BeanPropertyMap newMap = new BeanPropertyMap(newBuckets, bcount, _nextBucketIndex, _caseInsensitive); newMap.replace(newProperty); return newMap;
newBuckets[index] = new Bucket(newBuckets[index], propName, newProperty, _nextBucketIndex++); return new BeanPropertyMap(newBuckets, _size+1, _nextBucketIndex, _caseInsensitive); BeanPropertyMap newMap = new BeanPropertyMap(newBuckets, bcount, _nextBucketIndex, _caseInsensitive); 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<SettableBeanProperty> it = iterator(); ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(); 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<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(transformer); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } newProps.add(prop); } // should we try to re-index? Ordering probably changed but called probably doesn't want changes... return new BeanPropertyMap(newProps, _caseInsensitive); }
/** * 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<SettableBeanProperty> it = iterator(); ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(); 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<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(transformer); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } newProps.add(prop); } // should we try to re-index? Ordering probably changed but called probably doesn't want changes... return new BeanPropertyMap(newProps, _caseInsensitive); }
protected BuilderAndPropertyMap constructBeanDeserializerBuilder(JavaType type) { BeanDescription beanDesc = serializerProvider.getConfig().introspect(type); BeanDeserializerBuilder builder; CustomBeanDeserializerFactory factory = CustomBeanDeserializerFactory.instance; DeserializationContext ctxt = ((DefaultDeserializationContext) deserializationContext).copy(); try { Field field = DeserializationContext.class.getDeclaredField("_config"); field.setAccessible(true); field.set(ctxt, deserializationConfig); // copy from factory.buildBeanDeserializer() ValueInstantiator valueInstantiator = factory.findValueInstantiator(ctxt, beanDesc); builder = new BeanDeserializerBuilder(beanDesc, ctxt); builder.setValueInstantiator(valueInstantiator); factory.addBeanProps(ctxt, beanDesc, builder); factory.addObjectIdReader(ctxt, beanDesc, builder); factory.addBackReferenceProperties(ctxt, beanDesc, builder); factory.addInjectables(ctxt, beanDesc, builder); } catch (Exception e) { throw new RuntimeException("Unexpected exception", e); } List<SettableBeanProperty> properties = new ArrayList<>(); Iterator<SettableBeanProperty> propertiesIter = builder.getProperties(); while (propertiesIter.hasNext()) { properties.add(propertiesIter.next()); } BeanPropertyMap propertyMap = new BeanPropertyMap(false, properties, Collections.<String, List<PropertyName>>emptyMap()); return new BuilderAndPropertyMap(builder, propertyMap, beanDesc); }
BeanPropertyMap propertyMap = new BeanPropertyMap(props); propertyMap.assignIndexes();