/*-
 * ~~~~~~licensing~~~~~~
 * object-producer-core
 * ==========
 * Copyright (C) 2020 - 2022 EmDev LLC
 * ==========
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.platform.core.producer.executor.objectmodel;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.JsonObject;

import ru.entaxy.platform.base.objects.EntaxyObject.FIELDS;

public class FactoredObjectProxy extends FactoredObject {

	private static final Logger log = LoggerFactory.getLogger(FactoredObjectProxy.class);
	
	public static final String IS_PROXY_FIELD = "isProxy";
	
	public static final String UNKNOWN_PROXIED_FACTORY_ID = "__##";

	public static JsonObject getDefaultOrigin() {
		JsonObject result = new JsonObject();
		result.addProperty(FIELDS.FACTORY_ID, UNKNOWN_PROXIED_FACTORY_ID);
		result.addProperty(IS_PROXY_FIELD, true);
		return result;
	}
	
	public static boolean isProxy(JsonObject jsonObject) {
		try {
			
			if (!jsonObject.has(IS_PROXY_FIELD))
				return false;
			boolean isRef = jsonObject.get(IS_PROXY_FIELD).getAsBoolean();
			return isRef;
		} catch (Exception e) {
			return false;
		}
		
	}
	
	public FactoredObjectProxy(ObjectModel objectModel) {
		super(objectModel);
	}

	@Override
	public void wrap(JsonObject object, Map<String, Object> context, String path) {
		super.wrap(object, context, path);
	}
	
}
