本文整理汇总了Java中com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider.addFilter方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFilterProvider.addFilter方法的具体用法?Java SimpleFilterProvider.addFilter怎么用?Java SimpleFilterProvider.addFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
的用法示例。
在下文中一共展示了SimpleFilterProvider.addFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultObjectMapper
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
private ObjectMapper getDefaultObjectMapper(boolean xml, boolean details, TreeNode<String, Boolean> perms) {
if (perms == null) {
throw new NullPointerException("Permissions may not be null");
}
ObjectMapper om = xml ? new XmlMapper() : new ObjectMapper();
om.setSerializationInclusion(JsonInclude.Include.NON_NULL);
SimpleModule mod = new SimpleModule();
for (Map.Entry<Class, BaseSerializer> entry : serializers.entrySet()) {
mod.addSerializer(entry.getKey(), entry.getValue());
}
mod.addDeserializer(ItemStack.class, new ItemStackDeserializer());
mod.addDeserializer(BlockState.class, new BlockStateDeserializer());
mod.addDeserializer(ItemStackSnapshot.class, new ItemStackSnapshotDeserializer());
mod.addDeserializer(Location.class, new LocationDeserializer());
om.registerModule(mod);
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
filterProvider.addFilter(BaseFilter.ID, new BaseFilter(details, perms));
om.setFilterProvider(filterProvider);
om.setAnnotationIntrospector(new AnnotationIntrospector(details));
return om;
}
示例2: JsonManager
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
/**
* Create a new JsonManager
* @param theClass The class to create a json manager for (yes, also in the diamonds).
*/
public JsonManager (Class<T> theClass) {
this.theClass = theClass;
this.mapper = new ObjectMapper();
mapper.addMixInAnnotations(Rectangle2D.class, Rectangle2DMixIn.class);
mapper.registerModule(new GeoJsonModule());
SimpleModule deser = new SimpleModule();
deser.addDeserializer(LocalDate.class, new JacksonSerializers.LocalDateStringDeserializer());
deser.addSerializer(LocalDate.class, new JacksonSerializers.LocalDateStringSerializer());
deser.addDeserializer(Rectangle2D.class, new Rectangle2DDeserializer());
mapper.registerModule(deser);
mapper.getSerializerProvider().setNullKeySerializer(new JacksonSerializers.MyDtoNullKeySerializer());
filters = new SimpleFilterProvider();
filters.addFilter("bbox", SimpleBeanPropertyFilter.filterOutAllExcept("west", "east", "south", "north"));
this.writer = mapper.writer(filters);
}
示例3: newWriter
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
ObjectWriter newWriter(final boolean locationInfo, final boolean properties, final boolean compact) {
final SimpleFilterProvider filters = new SimpleFilterProvider();
final Set<String> except = new HashSet<>(2);
if (!locationInfo) {
except.add(this.getPropertNameForSource());
}
if (!properties) {
except.add(this.getPropertNameForContextMap());
}
except.add(this.getPropertNameForNanoTime());
filters.addFilter(Log4jLogEvent.class.getName(), SimpleBeanPropertyFilter.serializeAllExcept(except));
final ObjectWriter writer = this.newObjectMapper().writer(compact ? this.newCompactPrinter() : this.newPrettyPrinter());
return writer.with(filters);
}
示例4: consumeResults
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
@Override
public void consumeResults(ComparisonResult<T> comparisonResult, ResultConsumerConfiguration resultConsumerConfiguration) {
try {
SimpleFilterProvider fp = new SimpleFilterProvider();
Set<String> includedFields = new HashSet<String>();
includedFields.add("name");
includedFields.add("implementationPreference");
includedFields.add("timestamp");
includedFields.add("resultType");
includedFields.add("protoplastDurationNs");
includedFields.add("evolvedDurationNs");
if (comparisonResult.getResultType().isError() && resultConsumerConfiguration.shouldPrintDetailsOnError()) {
includedFields.add("protoplastArguments");
includedFields.add("protoplastValue");
includedFields.add("protplastException");
includedFields.add("evolvedArguments");
includedFields.add("evolvedValue");
includedFields.add("evolvedException");
}
if (resultConsumerConfiguration.shouldPrintBothArguments()) {
includedFields.add("protoplastArguments");
includedFields.add("evolvedArguments");
}
if (resultConsumerConfiguration.shouldPrintResults()) {
includedFields.add("protoplastValue");
includedFields.add("protplastException");
includedFields.add("evolvedValue");
includedFields.add("evolvedException");
}
fp.addFilter(FILTER_NAME, SimpleBeanPropertyFilter.filterOutAllExcept(includedFields));
String json = objectMapper.writer(fp).writeValueAsString(JsonComparisonResult.from(comparisonResult, resultConsumerConfiguration));
evolutionLog.debug(json);
} catch (JsonProcessingException e) {
log.error("Error creating json comparison result", e);
}
}
示例5: outfitMetadataFilter
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
/**
* Outfit the given {@link ObjectMapper} with a filter that will treat all metadata map entries as transient.
*
* @param om object mapper to modify
*/
private static void outfitMetadataFilter(ObjectMapper om) {
final String filterName = "exclude-metadata";
SimpleFilterProvider filters = new SimpleFilterProvider();
filters.addFilter(filterName, new MetadataPropertyFilter());
om.setAnnotationIntrospector(new JsonWrapperIntrospector(filterName));
om.setFilterProvider(filters);
}
示例6: addRolesFilter
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
@PostConstruct
public void addRolesFilter() {
if (jsonFilters == null || jsonFilters.isEmpty()) {
return;
}
// Register filter
final SimpleFilterProvider filterProvider = new SimpleFilterProvider();
for (final AbstractJsonFilter jsonFilter : jsonFilters) {
filterProvider.addFilter(jsonFilter.getFilterIdentifier(), jsonFilter);
}
objectMapper.setConfig(objectMapper.getSerializationConfig().withFilters(filterProvider));
}
示例7: registerFilters
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
public void registerFilters(ObjectMapper mapper) {
logger.debug("Registering jackson privacy filters");
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
filterProvider.addFilter("affiliatePrivacyFilter", new InternalPrivacyFilter(Affiliate.PRIVATE_FIELDS) );
filterProvider.addFilter("memberDtoPrivacyFilter", new InternalPrivacyFilter(MemberDTO.PRIVATE_FIELDS) );
mapper.setFilters(filterProvider);
}
示例8: StenoEncoder
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
StenoEncoder(final JsonFactory jsonFactory, final ObjectMapper objectMapper) {
// Initialize object mapper;
_objectMapper = objectMapper;
_objectMapper.setAnnotationIntrospector(new StenoAnnotationIntrospector(_objectMapper));
final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(!DEFAULT_REDACT_NULL));
// Initialize this here based on the above code, if it was initialized at the declaration site then things
// could get out of sync
_redactEnabled = true;
_objectMapper.setFilterProvider(simpleFilterProvider);
// Setup writing of Date/DateTime values
_objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
_objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
_objectMapper.setDateFormat(new StdDateFormat());
// Simple module with customizations
final SimpleModule module = new SimpleModule();
module.setSerializerModifier(new StenoBeanSerializerModifier(this));
_objectMapper.registerModule(module);
// Throwable mix-in
_objectMapper.setMixIns(Collections.singletonMap(Throwable.class, ThrowableMixIn.class));
// After burner to improve data-bind performance
_objectMapper.registerModule(new AfterburnerModule());
// Serialization strategies
_listsSerialziationStrategy = new ListsSerialziationStrategy(this, jsonFactory, _objectMapper);
_objectAsJsonSerialziationStrategy = new ObjectAsJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
_objectSerialziationStrategy = new ObjectSerialziationStrategy(this, jsonFactory, _objectMapper);
_mapOfJsonSerialziationStrategy = new MapOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
_mapSerialziationStrategy = new MapSerialziationStrategy(this, jsonFactory, _objectMapper);
_arrayOfJsonSerialziationStrategy = new ArrayOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper);
_arraySerialziationStrategy = new ArraySerialziationStrategy(this, jsonFactory, _objectMapper);
_standardSerializationStrategy = new StandardSerializationStrategy(this, jsonFactory, _objectMapper);
}
示例9: setRedactEnabled
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
/**
* Enables/Disables redaction support when serializing complex objects. Redacted fields/properties marked
* with the @LogRedact annotation will be output as a string with the value "{@code <REDACTED>}".
*
* @param redactEnabled - true to filter out redacted fields
*
* @since 1.1.0
*/
public void setRedactEnabled(final boolean redactEnabled) {
final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
if (redactEnabled) {
simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(!_redactNull));
} else {
simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID,
SimpleBeanPropertyFilter.serializeAllExcept(Collections.<String>emptySet()));
}
_objectMapper.setFilterProvider(simpleFilterProvider);
_redactEnabled = redactEnabled;
}
示例10: setRedactNull
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
/**
* Enables/Disables output of null for redacted fields when serializing complex objects.
*
* @param redactNull - true to redact null values, assuming redactEnabled is true
*
* @since 1.1.0
*/
public void setRedactNull(final boolean redactNull) {
if (_redactEnabled) {
final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(!redactNull));
_objectMapper.setFilterProvider(simpleFilterProvider);
}
_redactNull = redactNull;
}
示例11: setUp
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Mockito.doReturn(Boolean.FALSE).when(_encoder).isInjectBeanIdentifier();
_objectMapper = new ObjectMapper();
_objectMapper.setAnnotationIntrospector(new StenoAnnotationIntrospector(_objectMapper));
final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider();
simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(false));
_objectMapper.setFilterProvider(simpleFilterProvider);
final SimpleModule module = new SimpleModule();
module.setSerializerModifier(new StenoBeanSerializerModifier(_encoder));
_objectMapper.registerModule(module);
}
示例12: JsonSerializer
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
/**
* Create a JSON serializer for these validation results.
* @param results
*/
public JsonSerializer (FeedValidationResultSet results) {
super(results);
mapper = new ObjectMapper();
mapper.addMixInAnnotations(Rectangle2D.class, Rectangle2DMixIn.class);
SimpleModule deser = new SimpleModule();
deser.addDeserializer(Rectangle2D.class, new Rectangle2DDeserializer());
mapper.registerModule(deser);
SimpleFilterProvider filters = new SimpleFilterProvider();
filters.addFilter("bbox", SimpleBeanPropertyFilter.filterOutAllExcept("west", "east", "south", "north"));
writer = mapper.writer(filters);
}
示例13: getBody
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
@Override
public String getBody() throws Exception {
Set<String> properties = new HashSet<String>();
for (String field : fields) {
properties.add(field);
}
SimpleBeanPropertyFilter filter = new SimpleBeanPropertyFilter.FilterExceptFilter(properties);
SimpleFilterProvider provider = new SimpleFilterProvider();
provider.addFilter("update inventory request filter", filter);
return mapper.writer(provider).writeValueAsString(inventory);
}
示例14: init
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
protected void init() {
mapper.addMixInAnnotations(Object.class, PropertyFilterMixIn.class);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.PROTECTED_AND_PUBLIC);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.PROTECTED_AND_PUBLIC);
registerModules(mapper);
mapper.configure(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS, true);
mapper.setPropertyNamingStrategy(getPropertyNamingStrategy());
SimpleFilterProvider provider = new SimpleFilterProvider();
provider.addFilter("property_filter", SimpleBeanPropertyFilter.serializeAllExcept(Sets.<String>newHashSet()));
mapper.setFilters(provider);
}
示例15: getCustomFilterProvider
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; //导入方法依赖的package包/类
public static SimpleFilterProvider getCustomFilterProvider() {
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
for (Map.Entry<Class<? extends HistoryEvent>, Class> mixInFilter : getDefaultMixInFilters().entrySet()) {
String jsonFilterId = getJsonFilterAnnotationValue(mixInFilter.getValue());
if (jsonFilterId != null) {
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept("");
// TODO: add extension mechanism to declare filter values via ElasticSearchHistoryPluginConfiguration
filterProvider.addFilter(jsonFilterId, filter);
}
}
return filterProvider;
}