
jsonvalues.JsValueLens Maven / Gradle / Ivy
package jsonvalues;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import static java.util.Objects.requireNonNull;
/**
Represent a Lens which focus is the value of a Json
@param the type of the whole part, an array or an object */
class JsValueLens> extends Lens {
JsValueLens(final JsPath path) {
super(json -> requireNonNull(json).get(path),
value -> json -> requireNonNull(json).set(path,
requireNonNull(value)
)
);
}
static JsValueLens of(final String key) {
return new JsValueLens<>(JsPath.fromKey(requireNonNull(key)));
}
static JsValueLens of(int index) {
return new JsValueLens<>(JsPath.fromIndex(index));
}
static > JsValueLens of(JsPath path) {
return new JsValueLens<>(path);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy