2
|
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
|
|
3 |
// found in the LICENSE file.
|
|
4 |
|
|
5 |
package org.chromium.sdk.internal.protocolparser;
|
|
6 |
|
|
7 |
import java.util.Set;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* Implementation of {@link JsonValueCondition} for enum-typed values.
|
|
11 |
* User is supposed to subclass it and specify allowed enum constants in constructor.
|
|
12 |
* @param <T> type of value
|
|
13 |
*/
|
|
14 |
public abstract class EnumValueCondition<T extends Enum<T>> implements JsonValueCondition<T> {
|
|
15 |
private final Set<T> allowedValues;
|
|
16 |
protected EnumValueCondition(Set<T> allowedValues) {
|
|
17 |
this.allowedValues = allowedValues;
|
|
18 |
}
|
|
19 |
|
|
20 |
public boolean conforms(T value) {
|
|
21 |
return allowedValues.contains(value);
|
|
22 |
}
|
|
23 |
}
|