@Component public class GraphqlUtils extends Object
| Constructor and Description |
|---|
GraphqlUtils() |
| Modifier and Type | Method and Description |
|---|---|
<T> Method |
getGetter(Class<T> clazz,
Field field)
Retrieves the getter for the given field on the given field
|
<T> T |
getInputObject(Map<String,Object> map,
Class<T> clazz)
This method returns a GraphQL input object, as defined in the GraphQL schema, from the Map that has been read
from the JSON object sent to the server.
|
<T> List<T> |
getListInputObjects(List<Map<String,Object>> list,
Class<T> clazz)
This method returns a list of instances of the given class, from a list of
Map. |
String |
getPascalCase(String name)
Returns the given name in PascalCase.
|
<T> Method |
getSetter(Class<T> clazz,
Field field)
Retrieves the setter for the given field on the given field
|
Object |
invokeGetter(Object object,
String fieldName)
Invoke the getter for the given field name, on the given object.
|
void |
invokeSetter(Object object,
Field field,
Object value)
Invoke the setter for the given field, on the given object.
|
void |
invokeSetter(Object object,
String fieldName,
Object value)
Invoke the setter for the
Field of the given name, on the given object. |
public String getPascalCase(String name)
name - public <T> T getInputObject(Map<String,Object> map, Class<T> clazz)
T - The class expected to be returnedmap - The map, read from the JSON in the GraphQL request. Only the part of the map, related to the expected
class is sent.t - An empty instance of the expected type. This instance's fields will be set by this method, from the
value in the mappublic <T> List<T> getListInputObjects(List<Map<String,Object>> list, Class<T> clazz)
Map. This is used on
server-side, to map the input read from the JSON into the InputType that have been declared in the GraphQL
schema.T - list - clazz - public <T> Method getSetter(Class<T> clazz, Field field)
T - t - field - public <T> Method getGetter(Class<T> clazz, Field field)
T - t - field - public Object invokeGetter(Object object, String fieldName)
RuntimeExceptionobject - fieldName - RuntimeException - If any exception occurspublic void invokeSetter(Object object, Field field, Object value)
RuntimeExceptionobject - field - value - RuntimeException - If any exception occurspublic void invokeSetter(Object object, String fieldName, Object value)
Field of the given name, on the given object. All check exceptions are hidden
in a RuntimeExceptionobject - fieldName - value - RuntimeException - If any exception occursCopyright © 2020. All rights reserved.