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

Unified 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: Adding empty file to force creation. 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/java/src/org/chromium/mojo/system/Flags.java
diff --git a/mojo/public/java/src/org/chromium/mojo/system/Flags.java b/mojo/public/java/src/org/chromium/mojo/system/Flags.java
new file mode 100644
index 0000000000000000000000000000000000000000..bfce6e471241d22c76871f66f519b372713315ea
--- /dev/null
+++ b/mojo/public/java/src/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;
+
+/**
+ * Base class for bit field used as flags.
+ *
+ * @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) {
+ 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;
+ }
+
+}
« no previous file with comments | « mojo/public/java/src/org/chromium/mojo/system/DataPipe.java ('k') | mojo/public/java/src/org/chromium/mojo/system/Handle.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698