Record Class JSONValue
java.lang.Object
java.lang.Record
com.github.nedelis.jc4j.jsonvalue.JSONValue
This class is used to wrap a json value; After wrapping a json value you can
call
toJavaValue(Object) which will return you converted JSONValue-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.objectsMapToJsonValuesMap(@NotNull Map<String, ?> objectsMap) Converts map of objects to a map of JSON valuesobjectsToJsonValues(@NotNull List<?> values) Converts list of objects to a list of JSON valuesstatic @NotNull JSONValueShortcut for JSONValue constructor<T> TtoJavaValue(@NotNull IJSONValueType<T> type) Converting some json value into its representation in java; if value can't be converted, returns null<T> TtoJavaValue(T def) Converting some json value into its representation in java; if value can't be converted, returns the given default valuefinal StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
JSONValue
Creates an instance of aJSONValuerecord class.- Parameters:
value- the value for thevaluerecord component
-
-
Method Details
-
of
Shortcut for JSONValue constructor- Parameters:
value- some json value- Returns:
- new JSONValue
-
objectsToJsonValues
Converts list of objects to a list of JSON values- Parameters:
values- values to convert- Returns:
- list of JSON values
-
objectsMapToJsonValuesMap
public static Map<String,JSONValue> objectsMapToJsonValuesMap(@NotNull @NotNull Map<String, ?> objectsMap) Converts map of objects to a map of JSON values- Parameters:
objectsMap- objects map to convert- Returns:
- map of JSON values
-
toJavaValue
public <T> T toJavaValue(T def) Converting some json value into its representation in java; if value can't be converted, returns the given default value- Type Parameters:
T- specifies which type the java value will be- Parameters:
def- default value that will be returned if the conversion failed; specifies the "T"- Returns:
- converted json value
-
toJavaValue
Converting some json value into its representation in java; if value can't be converted, returns null- Type Parameters:
T- specifies which type the java value will be- Parameters:
type- converter- Returns:
- converted json value
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-