Skip to content

Package: ImmutableProperty

ImmutableProperty

nameinstructionbranchcomplexitylinemethod
ImmutableProperty(String, Object)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
addChangeListener(Property.ChangeListener)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDefault()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getValue()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
removeChangeListener(Property.ChangeListener)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
resetToDefault()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setValue(Object)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
throwImmutableException()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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: * Mat Hansen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.common;
15:
16: import org.eclipse.emfforms.common.Property;
17:
18: /**
19: * Immutable implementation of a property.
20: *
21: * @author Mat Hansen <mhansen@eclipsesource.com>
22: * @since 1.15
23: *
24: * @param <T> the value type
25: */
26: public class ImmutableProperty<T> implements Property<T> {
27:
28:         private final String name;
29:         private final T immutableValue;
30:
31:         private void throwImmutableException() {
32:                 throw new IllegalStateException("Property is immutable and cannot be modified during runtime"); //$NON-NLS-1$
33:         }
34:
35:         /**
36:          * The constructor.
37:          *
38:          * @param name the name of the property
39:          * @param immutableValue the immutable value
40:          */
41:         public ImmutableProperty(String name, T immutableValue) {
42:                 this.name = name;
43:                 this.immutableValue = immutableValue;
44:         }
45:
46:         @Override
47:         public void setValue(T value) {
48:                 throwImmutableException();
49:         }
50:
51:         @Override
52:         public void addChangeListener(ChangeListener<T> listener) {
53:                 // silently ignore this
54:         }
55:
56:         @Override
57:         public void removeChangeListener(ChangeListener<T> listener) {
58:                 // silently ignore this
59:         }
60:
61:         @Override
62:         public String getName() {
63:                 return name;
64:         }
65:
66:         @Override
67:         public T getValue() {
68:                 return immutableValue;
69:         }
70:
71:         @Override
72:         public T getDefault() {
73:                 return immutableValue;
74:         }
75:
76:         @Override
77:         public T resetToDefault() {
78:                 return immutableValue;
79:         }
80:
81:         @Override
82:         public void dispose() {
83:                 // silently ignore this
84:         }
85:
86: }