Skip to content

Package: EMFFormsIdProviderImpl

EMFFormsIdProviderImpl

nameinstructionbranchcomplexitylinemethod
EMFFormsIdProviderImpl()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getId(EObject)
M: 0 C: 19
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.spreadsheet.core;
15:
16: import java.util.Collections;
17: import java.util.Map;
18: import java.util.WeakHashMap;
19:
20: import org.eclipse.emf.ecore.EObject;
21: import org.eclipse.emf.ecore.util.EcoreUtil;
22: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsIdProvider;
23: import org.osgi.service.component.annotations.Component;
24:
25: /**
26: * Simple implementation of the EMFFormsIdProvider which returns a generated UUID per EObject.
27: *
28: * @author Eugen Neufeld
29: *
30: */
31: @Component
32: public class EMFFormsIdProviderImpl implements EMFFormsIdProvider {
33:
34:         private final Map<EObject, String> cache = Collections.synchronizedMap(new WeakHashMap<EObject, String>());
35:
36:         /**
37:          * {@inheritDoc}
38:          *
39:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsIdProvider#getId(org.eclipse.emf.ecore.EObject)
40:          */
41:         @Override
42:         public String getId(EObject eObject) {
43:•                if (!cache.containsKey(eObject)) {
44:                         final String uuid = EcoreUtil.generateUUID();
45:                         cache.put(eObject, uuid);
46:                 }
47:                 return cache.get(eObject);
48:         }
49:
50: }