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

org.dominokit.jackson.ObjectReader Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
/*
 * Copyright 2013 Nicolas Morel
 *
 * 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 org.dominokit.jackson;

import org.dominokit.jackson.deser.array.ArrayJsonDeserializer;
import org.dominokit.jackson.exception.JsonDeserializationException;

/**
 * Reads a JSON input and return an object
 *
 * 

Example : * *

 * public class Person {
 *     public String firstName, lastName;
 * }
 *
 * public interface PersonReader extends ObjectReader<Person> {}
 *
 * PersonReader reader = new PersonReaderMapperImpl();
 * Person person = reader.read("{\"firstName\":\"Nicolas\",\"lastName\":\"Morel\"}");
 *
 * person.firstName ==> "Nicolas"
 * person.lastName  ==> "Morel"
 * 
* * @param Type of the read object */ public interface ObjectReader { /** * Reads a JSON input into an object. * * @param input JSON input to read * @return the read object * @throws org.dominokit.jackson.exception.JsonDeserializationException if an exception occurs * while reading the input */ T read(String input) throws JsonDeserializationException; /** * Reads a JSON input into an object. * * @param input JSON input to read * @param ctx Context for the full reading process * @return the read object * @throws org.dominokit.jackson.exception.JsonDeserializationException if an exception occurs * while reading the input */ T read(String input, JsonDeserializationContext ctx) throws JsonDeserializationException; /** * Reads a JSON input into an array object. * * @param input JSON input to read * @param arrayCreator Creator for initializing new instance of an array of specific length * @return the read array object * @throws org.dominokit.jackson.exception.JsonDeserializationException if an exception occurs * while reading the input */ T[] readArray(String input, ArrayJsonDeserializer.ArrayCreator arrayCreator) throws JsonDeserializationException; /** * Reads a JSON input into an array object. * * @param input JSON input to read * @param ctx Context for the full reading process * @param arrayCreator Creator for initializing new instance of an array of specific length * @return the read array object * @throws org.dominokit.jackson.exception.JsonDeserializationException if an exception occurs * while reading the input */ T[] readArray( String input, JsonDeserializationContext ctx, ArrayJsonDeserializer.ArrayCreator arrayCreator) throws JsonDeserializationException; /** * getDeserializer. * * @return a {@link org.dominokit.jackson.JsonDeserializer} object. */ JsonDeserializer getDeserializer(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy