Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Jackson Data Binding Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson Databind Source Code files are provided in the source packge (jackson-databind-2.14.0-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Databind Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/databind/util/EnumValues.java
package com.fasterxml.jackson.databind.util; import java.util.*; import com.fasterxml.jackson.core.SerializableString; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.MapperConfig; /** * Helper class used for storing String serializations of {@code Enum}s, * to match to/from external representations. */ public final class EnumValues implements java.io.Serializable { private static final long serialVersionUID = 1; private final Class<Enum<?>> _enumClass; private final Enum<?>[] _values; private final SerializableString[] _textual; private transient EnumMap<?,SerializableString> _asMap; private EnumValues(Class<Enum<?>> enumClass, SerializableString[] textual) { _enumClass = enumClass; _values = enumClass.getEnumConstants(); _textual = textual; } /** * NOTE: do NOT call this if configuration may change, and choice between toString() * and name() might change dynamically. */ public static EnumValues construct(SerializationConfig config, Class<Enum<?>> enumClass) { if (config.isEnabled(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)) { return constructFromToString(config, enumClass); } return constructFromName(config, enumClass); } public static EnumValues constructFromName(MapperConfig<?> config, Class<Enum<?>> enumClass) { // Enum types with per-instance sub-classes need special handling Class<? extends Enum<?>> enumCls = ClassUtil.findEnumType(enumClass); Enum<?>[] enumValues = enumCls.getEnumConstants(); if (enumValues == null) { throw new IllegalArgumentException("Cannot determine enum constants for Class "+enumClass.getName()); } String[] names = config.getAnnotationIntrospector().findEnumValues(enumCls, enumValues, new String[enumValues.length]); SerializableString[] textual = new SerializableString[enumValues.length]; for (int i = 0, len = enumValues.length; i < len; ++i) { Enum<?> en = enumValues[i]; String name = names[i]; if (name == null) { name = en.name(); } textual[en.ordinal()] = config.compileString(name); } return construct(enumClass, textual); } public static EnumValues constructFromToString(MapperConfig<?> config, Class<Enum<?>> enumClass) { Class<? extends Enum<?>> cls = ClassUtil.findEnumType(enumClass); Enum<?>[] values = cls.getEnumConstants(); if (values == null) { // can this ever occur? throw new IllegalArgumentException("Cannot determine enum constants for Class "+enumClass.getName()); } ArrayList<String> external = new ArrayList<>(values.length); for (Enum<?> en : values) { external.add(en.toString()); } return construct(config, enumClass, external); } /** * @since 2.11 */ public static EnumValues construct(MapperConfig<?> config, Class<Enum<?>> enumClass, List<String> externalValues) { final int len = externalValues.size(); SerializableString[] textual = new SerializableString[len]; for (int i = 0; i < len; ++i) { textual[i] = config.compileString(externalValues.get(i)); } return construct(enumClass, textual); } /** * @since 2.11 */ public static EnumValues construct(Class<Enum<?>> enumClass, SerializableString[] externalValues) { return new EnumValues(enumClass, externalValues); } public SerializableString serializedValueFor(Enum<?> key) { return _textual[key.ordinal()]; } public Collection<SerializableString> values() { return Arrays.asList(_textual); } /** * Convenience accessor for getting raw Enum instances. * * @since 2.6 */ public List<Enum<?>> enums() { return Arrays.asList(_values); } /** * Method used for serialization and introspection by core Jackson code. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public EnumMap<?,SerializableString> internalMap() { EnumMap<?,SerializableString> result = _asMap; if (result == null) { // Alas, need to create it in a round-about way, due to typing constraints... Map<Enum<?>,SerializableString> map = new LinkedHashMap<Enum<?>,SerializableString>(); for (Enum<?> en : _values) { map.put(en, _textual[en.ordinal()]); } result = new EnumMap(map); } return result; } /** * @since 2.2 */ public Class<Enum<?>> getEnumClass() { return _enumClass; } }
⏎ com/fasterxml/jackson/databind/util/EnumValues.java
Or download all of them as a single archive file:
File name: jackson-databind-2.14.0-sources.jar File size: 1187952 bytes Release date: 2022-11-05 Download
⇒ Jackson Annotations Source Code
⇐ Download and Install Jackson Binary Package
2022-03-29, 47124👍, 0💬
Popular Posts:
JDK 11 jdk.compiler.jmod is the JMOD file for JDK 11 Compiler tool, which can be invoked by the "jav...
JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" co...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...