org.gecko.emf.jaxrs.EMFJsonAnnotationConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.gecko.emf.jaxrs Show documentation
Show all versions of org.gecko.emf.jaxrs Show documentation
Extension to load and save EMF EObjects using a MessageBodyReader or -Writer
The newest version!
/**
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Data In Motion - initial API and implementation
*/
package org.gecko.emf.jaxrs;
import java.lang.annotation.Annotation;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.gecko.emf.jaxrs.annotations.AnnotationConverter;
import org.gecko.emf.jaxrs.annotations.json.EMFJSONConfig;
import org.gecko.emf.jaxrs.annotations.json.RootElement;
import org.gecko.emf.json.constants.EMFJs;
import org.osgi.service.component.ComponentServiceObjects;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.eclipse.emfcloud.jackson.databind.EMFContext;
/**
* Converts the EMFJSON Annotations {@link RootElement} and {@link EMFJSONConfig} to EMF Load or Save Options
*
* @author Juergen Albert
* @since 24 Jun 2018
*/
@Component
public class EMFJsonAnnotationConverter implements AnnotationConverter {
@Reference
ComponentServiceObjects setServiceObjects;
/*
* (non-Javadoc)
* @see org.geckoprojects.emf.rest.api.AnnotationConverter#canHandle(java.lang.annotation.Annotation, boolean)
*/
@Override
public boolean canHandle(Annotation annotation, boolean serialize) {
return annotation instanceof RootElement || annotation instanceof EMFJSONConfig;
}
/*
* (non-Javadoc)
* @see org.geckoprojects.emf.rest.api.AnnotationConverter#convertAnnotation(java.lang.annotation.Annotation, boolean)
*/
@Override
public void convertAnnotation(Annotation annotation, boolean serialize, Map