當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleFilterProvider.addFilter方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:27,代碼來源:SerializeService.java

示例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);
}
 
開發者ID:conveyal,項目名稱:gtfs-lib,代碼行數:22,代碼來源:JsonManager.java

示例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);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:15,代碼來源:JacksonFactory.java

示例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);
    }
}
 
開發者ID:darwin-evolution,項目名稱:darwin,代碼行數:43,代碼來源:JacksonEvolutionResultConsumer.java

示例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);
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:13,代碼來源:JsonWrapper.java

示例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));
}
 
開發者ID:JanLoebel,項目名稱:uaa-service,代碼行數:14,代碼來源:JsonFilterMapperConfiguration.java

示例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);
}
 
開發者ID:IHTSDO,項目名稱:MLDS,代碼行數:8,代碼來源:JacksonConfigurer.java

示例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);
    }
 
開發者ID:ArpNetworking,項目名稱:logback-steno,代碼行數:39,代碼來源:StenoEncoder.java

示例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;
}
 
開發者ID:ArpNetworking,項目名稱:logback-steno,代碼行數:20,代碼來源:StenoEncoder.java

示例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;
}
 
開發者ID:ArpNetworking,項目名稱:logback-steno,代碼行數:16,代碼來源:StenoEncoder.java

示例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);
}
 
開發者ID:ArpNetworking,項目名稱:logback-steno,代碼行數:14,代碼來源:LogValueTest.java

示例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);
}
 
開發者ID:conveyal,項目名稱:gtfs-validator,代碼行數:16,代碼來源:JsonSerializer.java

示例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);
}
 
開發者ID:kleini,項目名稱:bricklink,代碼行數:12,代碼來源:UpdateInventoryRequest.java

示例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);
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:13,代碼來源:AbstractJacksonSerializer.java

示例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;
}
 
開發者ID:camunda,項目名稱:camunda-bpm-elasticsearch,代碼行數:14,代碼來源:JacksonMixInFilterModule.java


注:本文中的com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider.addFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。