类com.fasterxml.jackson.annotation.JsonIgnoreProperties源码实例Demo

下面列出了怎么用com.fasterxml.jackson.annotation.JsonIgnoreProperties的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: bistoury   文件: BeanSerializerFactory.java
/**
 * Overridable method that can filter out properties. Default implementation
 * checks annotations class may have.
 */
protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config,
                                                        BeanDescription beanDesc, List<BeanPropertyWriter> props)
{
    // 01-May-2016, tatu: Which base type to use here gets tricky, since
    //   it may often make most sense to use general type for overrides,
    //   but what we have here may be more specific impl type. But for now
    //   just use it as is.
    JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(beanDesc.getBeanClass(),
            beanDesc.getClassInfo());
    if (ignorals != null) {
        Set<String> ignored = ignorals.findIgnoredForSerialization();
        if (!ignored.isEmpty()) {
            Iterator<BeanPropertyWriter> it = props.iterator();
            while (it.hasNext()) {
                if (ignored.contains(it.next().getName())) {
                    it.remove();
                }
            }
        }
    }
    return props;
}
 
源代码2 项目: mantis   文件: AppJobClustersMap.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public AppJobClustersMap(@JsonProperty("version") String version,
                         @JsonProperty("timestamp") long ts,
                         @JsonProperty("mappings") Map<String, Object> mappings) {
    checkNotNull(mappings, "mappings");
    checkNotNull(version, "version");
    this.timestamp = ts;
    if (!version.equals(VERSION_1)) {
        throw new IllegalArgumentException("version " + version + " is not supported");
    }
    this.version = version;

    mappings.entrySet()
            .stream()
            .forEach(e -> this.mappings.put(e.getKey(), (Map<String, String>) e.getValue()));
}
 
源代码3 项目: mantis   文件: JobInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public JobInfo(
        @JsonProperty("name") final String name,
        @JsonProperty("description") final String description,
        @JsonProperty("numberOfStages") final int numberOfStages,
        @JsonProperty("parameterInfo") final Map<String, ParameterInfo> parameterInfo,
        @JsonProperty("sourceInfo") final MetadataInfo sourceInfo,
        @JsonProperty("sinkInfo") final MetadataInfo sinkInfo,
        @JsonProperty("stages") final Map<Integer, StageInfo> stages) {
    super(name, description);
    this.numberOfStages = numberOfStages;
    this.parameterInfo = parameterInfo;
    this.sourceInfo = sourceInfo;
    this.sinkInfo = sinkInfo;
    this.stages = stages;
}
 
源代码4 项目: mantis   文件: StageScalingPolicy.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public StageScalingPolicy(@JsonProperty("stage") int stage,
                          @JsonProperty("min") int min, @JsonProperty("max") int max,
                          @JsonProperty("increment") int increment, @JsonProperty("decrement") int decrement,
                          @JsonProperty("coolDownSecs") long coolDownSecs,
                          @JsonProperty("strategies") Map<ScalingReason, Strategy> strategies) {
    this.stage = stage;
    this.min = min;
    this.max = Math.max(max, min);
    enabled = min != max && strategies != null && !strategies.isEmpty();
    this.increment = Math.max(increment, 1);
    this.decrement = Math.max(decrement, 1);
    this.coolDownSecs = coolDownSecs;
    this.strategies = strategies == null ? new HashMap<ScalingReason, Strategy>() : new HashMap<>(strategies);
}
 
源代码5 项目: steady   文件: Library.java
/**
 * Loops over all constructs in order to find the distinct set of {@link ProgrammingLanguage}s used to develop the library.
 * Note: If slow, it can maybe improved by using a JPQL query.
 *
 * @return a {@link java.util.Set} object.
 */
@JsonProperty(value = "developedIn")
@JsonView(Views.CountDetails.class)
@JsonIgnoreProperties(value = { "developedIn" }, allowGetters=true)
public Set<ProgrammingLanguage> getDevelopedIn() {
	if(this.developedIn==null) {
		this.developedIn = new HashSet<ProgrammingLanguage>();
		if(this.getConstructs()!=null) {
			for(ConstructId cid: this.getConstructs()) {
				if(!this.developedIn.contains(cid.getLang())) {
					this.developedIn.add(cid.getLang());
				}
			}
		}
	}
	return this.developedIn;
}
 
源代码6 项目: biliob_backend   文件: MySlice.java
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
@JsonIgnoreProperties({"sort", "pageable"})
public MySlice(
        @JsonProperty("content") List<T> content,
        @JsonProperty("number") Integer number,
        @JsonProperty("size") Integer size,
        @JsonProperty("first") Boolean first,
        @JsonProperty("numberOfElements") Integer numberOfElements,
        @JsonProperty("last") Boolean last) {
    this.content = content;
    this.number = number;
    this.size = size;
    this.last = last;
    this.first = first;
    this.numberOfElements = numberOfElements;
}
 
源代码7 项目: lams   文件: BeanSerializerFactory.java
/**
 * Overridable method that can filter out properties. Default implementation
 * checks annotations class may have.
 */
protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config,
        BeanDescription beanDesc, List<BeanPropertyWriter> props)
{
    // 01-May-2016, tatu: Which base type to use here gets tricky, since
    //   it may often make most sense to use general type for overrides,
    //   but what we have here may be more specific impl type. But for now
    //   just use it as is.
    JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(beanDesc.getBeanClass(),
            beanDesc.getClassInfo());
    if (ignorals != null) {
        Set<String> ignored = ignorals.findIgnoredForSerialization();
        if (!ignored.isEmpty()) {
            Iterator<BeanPropertyWriter> it = props.iterator();
            while (it.hasNext()) {
                if (ignored.contains(it.next().getName())) {
                    it.remove();
                }
            }
        }
    }
    return props;
}
 
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
        MapLikeType type, BeanDescription beanDesc, JsonFormat.Value formatOverrides,
        JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
{
    if (Multimap.class.isAssignableFrom(type.getRawClass())) {
        final AnnotationIntrospector intr = config.getAnnotationIntrospector();
        Object filterId = intr.findFilterId(config, (Annotated)beanDesc.getClassInfo());
        JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(Multimap.class,
                beanDesc.getClassInfo());
        Set<String> ignored = (ignorals == null) ? null : ignorals.getIgnored();
        return new MultimapSerializer(type, beanDesc,
                keySerializer, elementTypeSerializer, elementValueSerializer, ignored, filterId);
    }
    return null;
}
 
@Test
@Description(
        "This test verifies that all model classes within the 'org.eclipse.hawkbit.ddi.json.model' package are annotated with '@JsonIgnoreProperties(ignoreUnknown = true)'")
public void shouldCheckAnnotationsForAllModelClasses() throws IOException {
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
    String packageName = this.getClass().getPackage().getName();

    ImmutableSet<ClassPath.ClassInfo> topLevelClasses = ClassPath.from(loader).getTopLevelClasses(packageName);
    for (ClassPath.ClassInfo classInfo : topLevelClasses) {
        Class<?> modelClass = classInfo.load();
        if (modelClass.getSimpleName().contains("Test") || modelClass.isEnum()) {
            continue;
        }
        JsonIgnoreProperties annotation = modelClass.getAnnotation(JsonIgnoreProperties.class);
        assertThat(annotation).isNotNull();
        assertThat(annotation.ignoreUnknown()).isTrue();
    }
}
 
private List<JsonIgnoreProperties> getAnnotation(Class clazz) {
    List<JsonIgnoreProperties> annotations = new ArrayList<>();
    while (clazz != Object.class && clazz != null) {
        JsonIgnoreProperties annotation = (JsonIgnoreProperties) clazz.getDeclaredAnnotation(JsonIgnoreProperties.class);
        if (annotation != null) {
            annotations.add(annotation);
        }
        clazz = clazz.getSuperclass();
    }
    return annotations;
}
 
源代码11 项目: mantis   文件: StageWorkers.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public StageWorkers(@JsonProperty("jobCluster") String jobCluster,
                    @JsonProperty("jobId") String jobId,
                    @JsonProperty("stageNum") int stageNum,
                    @JsonProperty("workers") List<MantisWorker> workers) {
    this.jobCluster = jobCluster;
    this.jobId = jobId;
    this.stageNum = stageNum;
    this.workers = workers;
}
 
源代码12 项目: mantis   文件: JobDiscoveryInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public JobDiscoveryInfo(@JsonProperty("jobCluster") final String jobCluster,
                        @JsonProperty("jobId") final String jobId,
                        @JsonProperty("stageWorkersMap") final Map<Integer, StageWorkers> stageWorkersMap) {
    this.jobCluster = jobCluster;
    this.jobId = jobId;
    this.stageWorkersMap = stageWorkersMap;
}
 
源代码13 项目: mantis   文件: MantisWorker.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public MantisWorker(@JsonProperty("host") String host,
                    @JsonProperty("port") int port) {
    this.host = host;
    this.port = port;
}
 
源代码14 项目: mantis   文件: StreamJobClusterMap.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public StreamJobClusterMap(final String appName,
                           final Map<String, String> mappings) {
    this.appName = appName;
    this.mappings = mappings;
}
 
源代码15 项目: mantis   文件: JobDescriptor.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public JobDescriptor(
        @JsonProperty("jobInfo") JobInfo jobInfo,
        @JsonProperty("project") String project,
        @JsonProperty("version") String version,
        @JsonProperty("timestamp") long timestamp,
        @JsonProperty("readyForJobMaster") boolean readyForJobMaster) {
    this.jobInfo = jobInfo;
    this.version = version;
    this.timestamp = timestamp;
    this.project = project;
    this.readyForJobMaster = readyForJobMaster;
}
 
源代码16 项目: mantis   文件: MetadataInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public MetadataInfo(@JsonProperty("name") String name,
                    @JsonProperty("description") String description) {
    this.name = name;
    this.description = description;
}
 
源代码17 项目: mantis   文件: StageInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public StageInfo(@JsonProperty("stageNumber") int stageNumber,
                 @JsonProperty("description") String description) {
    this.stageNumber = stageNumber;
    this.description = description;
}
 
源代码18 项目: mantis   文件: ParameterInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public ParameterInfo(@JsonProperty("name") String name,
                     @JsonProperty("description") String description,
                     @JsonProperty("defaultValue") String defaultValue,
                     @JsonProperty("parmaterType") String parameterType,
                     @JsonProperty("validatorDescription") String validatorDescription,
                     @JsonProperty("required") boolean required) {
    this.name = name;
    this.description = description;
    this.defaultValue = defaultValue;
    this.parameterType = parameterType;
    this.validatorDescription = validatorDescription;
    this.required = required;
}
 
源代码19 项目: mantis   文件: Parameter.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public Parameter(@JsonProperty("name") String name,
                 @JsonProperty("value") String value) {
    this.name = name;
    this.value = value;
}
 
源代码20 项目: mantis   文件: JobOwner.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public JobOwner(@JsonProperty("name") String name, @JsonProperty("teamName") String teamName,
                @JsonProperty("description") String description, @JsonProperty("contactEmail") String contactEmail,
                @JsonProperty("repo") String repo) {
    this.name = name;
    this.teamName = teamName;
    this.description = description;
    this.contactEmail = contactEmail;
    this.repo = repo;
}
 
源代码21 项目: mantis   文件: JobSla.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public JobSla(@JsonProperty("runtimeLimitSecs") long runtimeLimitSecs,
              @JsonProperty("minRuntimeSecs") long minRuntimeSecs,
              @JsonProperty("slaType") StreamSLAType slaType,
              @JsonProperty("durationType") MantisJobDurationType durationType,
              @JsonProperty("userProvidedType") String userProvidedType) {
    this.runtimeLimitSecs = Math.max(0L, runtimeLimitSecs);
    this.minRuntimeSecs = Math.max(0L, minRuntimeSecs);
    this.slaType = slaType == null ? StreamSLAType.Lossy : slaType;
    this.durationType = durationType;
    this.userProvidedType = userProvidedType;
}
 
源代码22 项目: mantis   文件: WorkerMigrationConfig.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public WorkerMigrationConfig(@JsonProperty("strategy") final MigrationStrategyEnum strategy,
                             @JsonProperty("configString") final String configString) {
    this.strategy = Optional.ofNullable(strategy).orElse(MigrationStrategyEnum.ONE_WORKER);
    this.configString = configString;
}
 
源代码23 项目: mantis   文件: NamedJobDefinition.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public NamedJobDefinition(@JsonProperty("jobDefinition") MantisJobDefinition jobDefinition,
                          @JsonProperty("owner") JobOwner owner) {
    this.jobDefinition = jobDefinition;
    this.owner = owner;
}
 
源代码24 项目: mantis   文件: StageScalingPolicy.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public Strategy(@JsonProperty("reason") ScalingReason reason,
                @JsonProperty("scaleDownBelowPct") double scaleDownBelowPct,
                @JsonProperty("scaleUpAbovePct") double scaleUpAbovePct,
                @JsonProperty("rollingCount") RollingCount rollingCount) {
    this.reason = reason;
    this.scaleDownBelowPct = scaleDownBelowPct;
    this.scaleUpAbovePct = Math.max(scaleDownBelowPct, scaleUpAbovePct);
    this.rollingCount = rollingCount == null ? new RollingCount(1, 1) : rollingCount;
}
 
源代码25 项目: mantis   文件: StageSchedulingInfo.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public StageSchedulingInfo(@JsonProperty("numberOfInstances") int numberOfInstances,
                           @JsonProperty("machineDefinition") MachineDefinition machineDefinition,
                           @JsonProperty("hardConstraints") List<JobConstraints> hardConstraints,
                           @JsonProperty("softConstraints") List<JobConstraints> softConstraints,
                           @JsonProperty("scalingPolicy") StageScalingPolicy scalingPolicy,
                           @JsonProperty("scalable") boolean scalable) {
    this.numberOfInstances = numberOfInstances;
    this.machineDefinition = machineDefinition;
    this.hardConstraints = hardConstraints;
    this.softConstraints = softConstraints;
    this.scalingPolicy = scalingPolicy;
    this.scalable = scalable;
}
 
源代码26 项目: mantis   文件: MachineDefinition.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public MachineDefinition(@JsonProperty("cpuCores") double cpuCores,
                         @JsonProperty("memoryMB") double memoryMB,
                         @JsonProperty("networkMbps") double networkMbps,
                         @JsonProperty("diskMB") double diskMB,
                         @JsonProperty("numPorts") int numPorts) {
    this.cpuCores = cpuCores;
    this.memoryMB = memoryMB;
    this.networkMbps = networkMbps == 0 ? defaultMbps : networkMbps;
    this.diskMB = diskMB;
    this.numPorts = Math.max(minPorts, numPorts);
}
 
源代码27 项目: mantis   文件: WorkerPorts.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public WorkerPorts(@JsonProperty("metricsPort") int metricsPort,
                   @JsonProperty("debugPort") int debugPort,
                   @JsonProperty("consolePort") int consolePort,
                   @JsonProperty("customPort") int customPort,
                   @JsonProperty("ports") List<Integer> ports) {
    this.metricsPort = metricsPort;
    this.debugPort = debugPort;
    this.consolePort = consolePort;
    this.customPort = customPort;
    this.ports = ports;
}
 
源代码28 项目: mantis   文件: GaugeMeasurement.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public GaugeMeasurement(@JsonProperty("event") String event,
                        @JsonProperty("value") double value) {
    this.event = event;
    this.value = value;
}
 
源代码29 项目: mantis   文件: CounterMeasurement.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public CounterMeasurement(@JsonProperty("event") String event,
                          @JsonProperty("count") long count) {
    this.event = event;
    this.count = count;
}
 
源代码30 项目: mantis   文件: Measurements.java
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public Measurements(
        @JsonProperty("name") String name,
        @JsonProperty("timestamp") long timestamp,
        @JsonProperty("counters") Collection<CounterMeasurement> counters,
        @JsonProperty("gauges") Collection<GaugeMeasurement> gauges,
        @JsonProperty("tags") Map<String, String> tags) {
    this.name = name;
    this.timestamp = timestamp;
    this.counters = counters;
    this.gauges = gauges;
    this.tags = tags;
}
 
 类方法
 同包方法