public class JsonLongAccessorImpl extends Object
Constructor and Description |
---|
JsonLongAccessorImpl(JsonAccessor<com.google.gson.JsonElement> parentAccessor) |
Modifier and Type | Method and Description |
---|---|
void |
add(com.google.gson.JsonObject root,
T newValue)
Add the given primitive value to the element this accessor points to for the
given
root . |
protected void |
appendRuntimeRelativePath(StringBuilder path) |
protected void |
appendStaticRelativePath(StringBuilder path,
boolean first) |
Optional<T> |
get(com.google.gson.JsonObject root)
Get the current value of the element this accessor points to for the given
root . |
protected JsonElementType<Long> |
getExpectedElementType() |
T |
getOrCreate(com.google.gson.JsonObject root,
Supplier<? extends T> newValueSupplier)
Get the current value of the element this accessor points to for the given
root ,
creating it and setting it if it hasn't been set yet. |
protected JsonAccessor<P> |
getParentAccessor() |
String |
getStaticAbsolutePath() |
void |
set(com.google.gson.JsonObject root,
T newValue)
Set the given value on the element this accessor points to for the given
root . |
protected com.google.gson.JsonElement |
toElement(T value) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
root
public JsonLongAccessorImpl(JsonAccessor<com.google.gson.JsonElement> parentAccessor)
protected JsonElementType<Long> getExpectedElementType()
public Optional<T> get(com.google.gson.JsonObject root) throws UnexpectedJsonElementTypeException
JsonAccessor
root
.root
- The root to be accessed.Optional
containing the current value pointed to by this accessor on the root
,
or Optional.empty()
if it doesn't exist.UnexpectedJsonElementTypeException
- If an element in the path has unexpected type,
preventing access to the element this accessor points to.public void set(com.google.gson.JsonObject root, T newValue) throws UnexpectedJsonElementTypeException
JsonAccessor
root
.root
- The root to be accessed.newValue
- The value to set.UnexpectedJsonElementTypeException
- If an element in the path has unexpected type, preventing
access to the element this accessor points to.public void add(com.google.gson.JsonObject root, T newValue) throws UnexpectedJsonElementTypeException
JsonAccessor
root
.
This method differs from JsonAccessor.set(JsonObject, Object)
:
set
.
JsonNull
, the current value
is replaced by an array containing the current value followed by the given value.
UnexpectedJsonElementTypeException
is thrown.
root
- The root to be accessed.newValue
- The value to add.UnexpectedJsonElementTypeException
- If an element in the path has unexpected type, preventing
write access to the element this accessor points to.public T getOrCreate(com.google.gson.JsonObject root, Supplier<? extends T> newValueSupplier) throws UnexpectedJsonElementTypeException
JsonAccessor
root
,
creating it and setting it if it hasn't been set yet.root
- The root to be accessed.newValueSupplier
- The value to set and return if the current value hasn't been set yet.root
, always non-null.UnexpectedJsonElementTypeException
- if the element already exists and is not of the expected type,
or if an element in the path has unexpected type, preventing access to the element this accessor
points to.protected com.google.gson.JsonElement toElement(T value)
protected void appendRuntimeRelativePath(StringBuilder path)
protected void appendStaticRelativePath(StringBuilder path, boolean first)
protected JsonAccessor<P> getParentAccessor()
public String getStaticAbsolutePath()
getStaticAbsolutePath
in interface JsonAccessor<T>
null
for the root accessor.Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved