| Index: mojo/public/java/org/chromium/mojo/system/Flags.java
|
| diff --git a/mojo/public/java/org/chromium/mojo/system/Flags.java b/mojo/public/java/org/chromium/mojo/system/Flags.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..87e5725d4edb1ba33bfa4fc5ab484540c84ca963
|
| --- /dev/null
|
| +++ b/mojo/public/java/org/chromium/mojo/system/Flags.java
|
| @@ -0,0 +1,48 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.mojo.system;
|
| +
|
| +/**
|
| + * TODO(qsr): Insert description here.
|
| + *
|
| + * @param <F> the type of the flags.
|
| + */
|
| +public abstract class Flags<F extends Flags<F>> {
|
| + private int mFlags;
|
| +
|
| + /**
|
| + * Dedicated constructor.
|
| + *
|
| + * @param flags initial value of the flag.
|
| + */
|
| + protected Flags(int flags) {
|
| + this.mFlags = flags;
|
| + }
|
| +
|
| + /**
|
| + * @return the computed flag.
|
| + */
|
| + public int getFlags() {
|
| + return mFlags;
|
| + }
|
| +
|
| + /**
|
| + * Change the given bit of this flag.
|
| + *
|
| + * @param value the new value of given bit.
|
| + * @return this.
|
| + */
|
| + protected F setFlag(int flag, boolean value) {
|
| + if (value) {
|
| + mFlags |= flag;
|
| + } else {
|
| + mFlags &= ~flag;
|
| + }
|
| + @SuppressWarnings("unchecked")
|
| + F f = (F) this;
|
| + return f;
|
| + }
|
| +
|
| +}
|
|
|