Unmarshal YAML.

@param yamlBytes YAML bytes
@param classType class type
@param <T> type of class
@return object from YAML
@throws IOException IO Exception
546839
public static <T extends YamlConfiguration> T unmarshal(final byte[] yamlBytes, final Class<T> classType) throws IOException {
        try (InputStream inputStream = new ByteArrayInputStream(yamlBytes)) {
            return new Yaml(new Constructor(classType)).loadAs(inputStream, classType);
        }
    }
484437
public static byte[] unmarshallByteArray(ObjectInput in) throws IOException {
      final int size = unmarshallSize(in);
      if (size == NULL_VALUE) {
         return null;
      } else if (size == 0) {
         return Util.EMPTY_BYTE_ARRAY;
      }
      byte[] array = new byte[size];
      in.readFully(array);
      return array;
   }
1295648
ModuleMarshal marshal(Class<?> sourceType)
  {
    ModuleMarshal marshal = _marshalSourceMap.get(sourceType);
    
    if (marshal == null) {
      marshal = marshalImpl(sourceType);
      _marshalSourceMap.put(sourceType, marshal);
    }
    
    return marshal;
  }
1062467
protected Object readValue (Class type, Class elementType, Class defaultType)
		throws YamlException, ParserException, TokenizerException {
		String tag = null, anchor = null;
		Event event = parser.peekNextEvent();

		switch (event.type) {
		case ALIAS:
			parser.getNextEvent();
			anchor = ((AliasEvent)event).anchor;
			Object value = anchors.get(anchor);
			if (value == null) throw new YamlReaderException("Unknown anchor: " + anchor);
			return value;
		case MAPPING_START:
		case SEQUENCE_START:
			tag = ((CollectionStartEvent)event).tag;
			anchor = ((CollectionStartEvent)event).anchor;
			break;
		case SCALAR:
			tag = ((ScalarEvent)event).tag;
			anchor = ((ScalarEvent)event).anchor;
			break;
		default:
		}

		return readValueInternal(this.chooseType(tag, defaultType, type), elementType, anchor);
	}
72894
public static <T> T unmarshal(InputStream is, ObjectMapper mapper) {
   return unmarshal(is, mapper, Collections.<String, String>emptyMap());
  }
355679
public static Map<String, Object> parseYamlString(String yaml) throws IOException {
        ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
        TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
        };
        return mapper.readValue(yaml, typeRef);
    }
393859
public static <T> T fromByteArrayKryo(byte[] data, Class<T> clazz) {
        return fromByteArrayKryo(data, clazz, null);
    }
981367
@JRubyMethod
    public static IRubyObject yaml_initialize(IRubyObject self, IRubyObject klass, IRubyObject ivars) {
        ((RubyObject)self).fastSetInstanceVariable("@class", klass);
        ((RubyObject)self).fastSetInstanceVariable("@ivars", ivars);
        return self;
    }
263381
public static byte[] toByteArrayKryo(Object obj, ClassLoader classLoader) {
        if (obj == null) {
            return null;
        }
        Kryo kryo = kryoPool.obtain();
        try {
            ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
            if (classLoader != null) {
                Thread.currentThread().setContextClassLoader(classLoader);
            }
            try {
                Output output = kryoOutputPool.obtain();
                try {
                    kryo.setClassLoader(classLoader != null ? classLoader : oldClassLoader);
                    // kryo.writeObject(output, obj);
                    kryo.writeClassAndObject(output, obj);
                    output.close();
                    return output.toBytes();
                } catch (Exception e) {
                    throw e instanceof SerializationException ? (SerializationException) e
                            : new SerializationException(e);
                } finally {
                    kryoOutputPool.free(output);
                }
            } finally {
                Thread.currentThread().setContextClassLoader(oldClassLoader);
            }
        } finally {
            kryoPool.free(kryo);
        }
    }
704822
public static DataSource createDataSource(final byte[] yamlBytes) throws SQLException, IOException {
        YamlRootShardingConfiguration config = YamlEngine.unmarshal(yamlBytes, YamlRootShardingConfiguration.class);
        return ShardingDataSourceFactory.createDataSource(config.getDataSources(), new ShardingRuleConfigurationYamlSwapper().swap(config.getShardingRule()), config.getProps());
    }
501357
public final static <T extends FastSerializable> T deserialize(
            final byte[] data, final Class<T> expectedType) throws IOException {
        final FastDeserializer in = new FastDeserializer(data);
        return in.readObject(expectedType);
    }
241881
public static TransformProcess fromYaml(String yaml) {
        try {
            return JsonMappers.getMapper().readValue(yaml, TransformProcess.class);
        } catch (IOException e) {
            //TODO proper exception message
            throw new RuntimeException(e);
        }
    }
1116404
@Override
    public final String fromBytes(Class targetClass, byte[] bytes)
    {

        try
        {
            return bytes != null ? new String(bytes, Constants.CHARSET_UTF8) : null;
        }
        catch (UnsupportedEncodingException e)
        {
            log.error("Unsupported encoding exception, Caused by {}.", e);
            throw new PropertyAccessException(e);
        }

    }
1103687
private static TypeSerializer<?>[] createRegisteredSubclassSerializers(
			LinkedHashSet<Class<?>> registeredSubclasses,
			ExecutionConfig executionConfig) {

		final TypeSerializer<?>[] subclassSerializers = new TypeSerializer[registeredSubclasses.size()];

		int i = 0;
		for (Class<?> registeredClass : registeredSubclasses) {
			subclassSerializers[i] = TypeExtractor.createTypeInfo(registeredClass).createSerializer(executionConfig);
			i++;
		}

		return subclassSerializers;
	}
47591
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
		in.defaultReadObject();

		// kryoRegistrations may be null if this Kryo serializer is deserialized from an old version
		if (kryoRegistrations == null) {
			this.kryoRegistrations = buildKryoRegistrations(
					type,
					registeredTypes,
					registeredTypesWithSerializerClasses,
					registeredTypesWithSerializers);
		}
	}
1101610
private Unmarshaller getUnMarshaller(final MarshallerFactory marshallerFactory, final ClassResolver classResolver)
            throws IOException {
        final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration();
        marshallingConfiguration.setVersion(2);
        marshallingConfiguration.setClassResolver(classResolver);
        return marshallerFactory.createUnmarshaller(marshallingConfiguration);
    }
563973
private void unmarshalIdentifier() throws Throwable {
    IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata();
    Object id = ((Key) nativeEntity.getKey()).getNameOrId();
    // If the ID is not a simple type...
    IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata();
    if (idClassMetadata != null) {
      Object wrappedId = idClassMetadata.getConstructor().invoke(id);
      id = wrappedId;
    }
    // Now set the ID (either simple or complex) on the Entity
    MethodHandle writeMethod = identifierMetadata.getWriteMethod();
    writeMethod.invoke(entity, id);
  }