All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mrenou.jacksonatic.internal.mapping.builder.parameter.ParameterCriteriaInternal Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2015 Morgan Renou ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.mrenou.jacksonatic.internal.mapping.builder.parameter;

import com.github.mrenou.jacksonatic.mapping.ParameterCriteria;

import java.util.List;

import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;

/**
 * Criteria to match a parameter by this type or this associated field name
 */
public class ParameterCriteriaInternal implements com.github.mrenou.jacksonatic.mapping.ParameterCriteria {

    private Class parameterClass;

    private String fieldName;

    private String jsonProperty;

    public static List parameterCriteriaToInternal(ParameterCriteria... parameterCriteriaArray) {
        return parameterCriteriaToInternal(asList(parameterCriteriaArray));
    }

    public static List parameterCriteriaToInternal(List parameterCriteriaList) {
        return parameterCriteriaList.stream().map(parameterCriteria -> (ParameterCriteriaInternal) parameterCriteria).collect(toList());
    }

    public ParameterCriteriaInternal(Class parameterClass, String fieldName, String jsonProperty) {
        this.parameterClass = parameterClass;
        this.fieldName = fieldName;
        this.jsonProperty = jsonProperty;
    }

    public Class getParameterClass() {
        return parameterClass;
    }

    public String getFieldName() {
        return fieldName;
    }

    public String getJsonProperty() {
        return jsonProperty;
    }

    @Override
    public ParameterCriteria mappedBy(String jsonProperty) {
        this.jsonProperty = jsonProperty;
        return this;
    }

    @Override
    public String toString() {
        return "ParameterCriteria{" +
                "parameterClass=" + parameterClass +
                ", jsonProperty='" + jsonProperty + '\'' +
                ", fieldName='" + fieldName + '\'' +
                '}';
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy