Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: plugins/org.chromium.sdk/src/org/chromium/sdk/internal/protocolparser/EnumValueCondition.java

Issue 11833010: Expose liveedit compile error data in SDK (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: fcr Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.sdk.internal.protocolparser; 5 package org.chromium.sdk.internal.protocolparser;
6 6
7 import java.util.EnumSet;
7 import java.util.Set; 8 import java.util.Set;
8 9
9 /** 10 /**
10 * Implementation of {@link JsonValueCondition} for enum-typed values. 11 * Implementation of {@link JsonValueCondition} for enum-typed values.
11 * User is supposed to subclass it and specify allowed enum constants in constru ctor. 12 * User is supposed to subclass it and specify allowed enum constants in constru ctor.
12 * @param <T> type of value 13 * @param <T> type of value
13 */ 14 */
14 public abstract class EnumValueCondition<T extends Enum<T>> implements JsonValue Condition<T> { 15 public abstract class EnumValueCondition<T extends Enum<T>> implements JsonValue Condition<T> {
15 private final Set<T> allowedValues; 16 private final Set<T> allowedValues;
16 protected EnumValueCondition(Set<T> allowedValues) { 17 protected EnumValueCondition(Set<T> allowedValues) {
17 this.allowedValues = allowedValues; 18 this.allowedValues = allowedValues;
18 } 19 }
20 protected EnumValueCondition(T singleAllowedValues) {
21 this.allowedValues = EnumSet.<T>of(singleAllowedValues);
22 }
19 23
20 public boolean conforms(T value) { 24 public boolean conforms(T value) {
21 return allowedValues.contains(value); 25 return allowedValues.contains(value);
22 } 26 }
23 27
24 public static String decorateEnumConstantName(String enumValue) { 28 public static String decorateEnumConstantName(String enumValue) {
25 return enumValue.toUpperCase().replace("-", "_"); 29 return enumValue.toUpperCase().replace("-", "_");
26 } 30 }
27 } 31 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698