Skip to content

Package: RendererUtil

RendererUtil

nameinstructionbranchcomplexitylinemethod
getStyleProperty(VTViewTemplateProvider, VElement, ViewModelContext, Class)
M: 0 C: 27
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2017 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: * stefan - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.model.common.util;
15:
16: import java.util.Set;
17:
18: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
19: import org.eclipse.emf.ecp.view.spi.model.VElement;
20: import org.eclipse.emf.ecp.view.template.model.VTStyleProperty;
21: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
22:
23: /**
24: * Util class for SWT Control Renderer.
25: *
26: * @author Stefan Dirix
27: * @since 1.14
28: */
29: public final class RendererUtil {
30:
31:         /**
32:          * Util Class Constructor.
33:          */
34:         private RendererUtil() {
35:
36:         }
37:
38:         /**
39:          * Returns a {@link VTStyleProperty} of the given class or {@code null} if none was found.
40:          *
41:          * @param templateProvider the {@link VTViewTemplateProvider}
42:          * @param vElement the {@link VElement}
43:          * @param context the {@link ViewModelContext}.
44:          * @param stylePropertyClass the style property class
45:          * @param <SP> stylePropertyClass
46:          *
47:          * @return the property or {@code null}
48:          */
49:         public static <SP extends VTStyleProperty> SP getStyleProperty(VTViewTemplateProvider templateProvider,
50:                 VElement vElement, ViewModelContext context, Class<SP> stylePropertyClass) {
51:                 final Set<VTStyleProperty> styleProperties = templateProvider
52:                         .getStyleProperties(vElement, context);
53:•                for (final VTStyleProperty styleProperty : styleProperties) {
54:•                        if (stylePropertyClass.isInstance(styleProperty)) {
55:                                 return stylePropertyClass.cast(styleProperty);
56:                         }
57:                 }
58:                 return null;
59:         }
60: }