01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.fix;
11:
12: import java.util.Map;
13:
14: import org.eclipse.core.runtime.Assert;
15:
16: import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
17:
18: /**
19: * Allows to retrieve clean up settings from given
20: * options keys.
21: * <p>
22: * Client should not extend this class.
23: * </p>
24: *
25: * @see CleanUpConstants
26: * @since 3.4
27: */
28: public class CleanUpOptions {
29:
30: private final Map fOptions;
31:
32: /**
33: * Create new CleanUpOptions instance. <code>options</code>
34: * maps named clean ups keys to {@link CleanUpConstants#TRUE} or
35: * {@link CleanUpConstants#FALSE}
36: *
37: * @param options map from String to String
38: * @see CleanUpConstants
39: */
40: public CleanUpOptions(Map options) {
41: fOptions = options;
42: }
43:
44: /**
45: * Is the option with the given <code>key</code> enabled?
46: *
47: * @param key the name of the option
48: * @return true if enabled, false if not enabled or unknown key
49: * @see CleanUpConstants
50: */
51: public boolean isEnabled(String key) {
52: Assert.isNotNull(key);
53:
54: Object value = fOptions.get(key);
55: return CleanUpConstants.TRUE == value
56: || CleanUpConstants.TRUE.equals(value);
57: }
58: }
|