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

Side by Side Diff: mojo/public/java/src/org/chromium/mojo/system/Flags.java

Issue 228723002: Java API for mojo system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 years, 8 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
(Empty)
1 // Copyright 2014 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.mojo.system;
6
7 /**
8 * Base class for bit field used as flags.
9 *
10 * @param <F> the type of the flags.
11 */
12 public abstract class Flags<F extends Flags<F>> {
13 private int mFlags;
14
15 /**
16 * Dedicated constructor.
17 *
18 * @param flags initial value of the flag.
19 */
20 protected Flags(int flags) {
21 mFlags = flags;
22 }
23
24 /**
25 * @return the computed flag.
26 */
27 public int getFlags() {
28 return mFlags;
29 }
30
31 /**
32 * Change the given bit of this flag.
33 *
34 * @param value the new value of given bit.
35 * @return this.
36 */
37 protected F setFlag(int flag, boolean value) {
38 if (value) {
39 mFlags |= flag;
40 } else {
41 mFlags &= ~flag;
42 }
43 @SuppressWarnings("unchecked")
44 F f = (F) this;
45 return f;
46 }
47
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698